Example #1
0
 /// <summary>Returns the info structure for dialog display settings.</summary>
 /// <param name="owner">The System.Windows.Forms.IWin32Window the dialog will display in front of.</param>
 private Credui.Info GetInfo(IWin32Window owner)
 {
     Credui.Info info = new Credui.Info();
     if (owner != null)
     {
         info.HwndParent = owner.Handle;
     }
     info.PszCaptionText = this.Caption;
     info.PszMessageText = this.Message;
     if (this.Banner != null)
     {
         info.HbmBanner = new Bitmap(this.Banner, CredentialsDialog.ValidBannerWidth, CredentialsDialog.ValidBannerHeight).GetHbitmap();
     }
     info.CbSize = Marshal.SizeOf(info);
     return(info);
 }
Example #2
0
        /// <summary>Returns a DialogResult indicating the user action.</summary>
        /// <param name="owner">The System.Windows.Forms.IWin32Window the dialog will display in front of.</param>
        /// <remarks>
        /// Sets the name, password and SaveChecked accessors to the state of the dialog as it was dismissed by the user.
        /// </remarks>
        private DialogResult ShowDialog(IWin32Window owner)
        {
            // set the api call parameters
            StringBuilder name = new StringBuilder(Credui.MaxUsernameLength);

            name.Append(this.Name);

            StringBuilder password = new StringBuilder(Credui.MaxPasswordLength);

            password.Append(this.Password);

            int saveChecked = Convert.ToInt32(this.SaveChecked);

            Credui.Info  info  = this.GetInfo(owner);
            Credui.Flags flags = this.GetFlags();

            // make the api call
            Credui.ReturnCodes code = Credui.PromptForCredentials(
                ref info,
                this.Target,
                IntPtr.Zero, 0,
                name, Credui.MaxUsernameLength,
                password, Credui.MaxPasswordLength,
                ref saveChecked,
                flags
                );

            // clean up resources
            if (this.Banner != null)
            {
                Gdi32.DeleteObject(info.HbmBanner);
            }

            // set the accessors from the api call parameters
            this.Name        = name.ToString();
            this.Password    = password.ToString();
            this.SaveChecked = Convert.ToBoolean(saveChecked);

            return(CredentialsDialog.GetDialogResult(code));
        }
Example #3
0
 /// <summary>Returns the info structure for dialog display settings.</summary>
 /// <param name="owner">The System.Windows.Forms.IWin32Window the dialog will display in front of.</param>
 private Credui.Info GetInfo(IWin32Window owner)
 {
     Credui.Info info = new Credui.Info();
     if (owner != null) info.HwndParent = owner.Handle;
     info.PszCaptionText = this.Caption;
     info.PszMessageText = this.Message;
     if (this.Banner != null)
     {
         info.HbmBanner = new Bitmap(this.Banner, CredentialsDialog.ValidBannerWidth, CredentialsDialog.ValidBannerHeight).GetHbitmap();
     }
     info.CbSize = Marshal.SizeOf(info);
     return info;
 }