/// <summary>
        /// </summary>
        protected WindowsFormsWebAuthenticationDialogBase(object ownerWindow)
        {
            // From MSDN (http://msdn.microsoft.com/en-us/library/ie/dn720860(v=vs.85).aspx):
            // The net session count tracks the number of instances of the web browser control.
            // When a web browser control is created, the net session count is incremented. When the control
            // is destroyed, the net session count is decremented. When the net session count reaches zero,
            // the session cookies for the process are cleared. SetQueryNetSessionCount can be used to prevent
            // the session cookies from being cleared for applications where web browser controls are being created
            // and destroyed throughout the lifetime of the application. (Because the application lives longer than
            // a given instance, session cookies must be retained for a longer periods of time.
            int sessionCount = NativeMethods.SetQueryNetSessionCount(NativeMethods.SessionOp.SESSION_QUERY);

            if (sessionCount == 0)
            {
                NativeMethods.SetQueryNetSessionCount(NativeMethods.SessionOp.SESSION_INCREMENT);
            }

            if (ownerWindow == null)
            {
                this.ownerWindow = null;
            }
            else if (ownerWindow is IWin32Window)
            {
                this.ownerWindow = (IWin32Window)ownerWindow;
            }
            else if (ownerWindow is IntPtr)
            {
                this.ownerWindow = new WindowsFormsWin32Window {
                    Handle = (IntPtr)ownerWindow
                };
            }
            else
            {
                throw new MsalException(MsalError.InvalidOwnerWindowType,
                                        "Invalid owner window type. Expected types are IWin32Window or IntPtr (for window handle).");
            }

            _webBrowser = new CustomWebBrowser();
            _webBrowser.PreviewKeyDown += WebBrowser_PreviewKeyDown;
            InitializeComponent();
        }
 // Methods
 public CustomWebBrowserEvent(CustomWebBrowser parent)
 {
     this.parent = parent;
 }