public static DialogResult ShowDialog(Form form, bool disposeForm) { DialogResult result = DialogResult.OK; #if !NDOC && !DESIGN if (form == null) { throw new ArgumentNullException("form"); } IntPtr lastWnd = Win32Window.GetActiveWindow(); // it seems that Form.Close() method processes Window Queue itself that is why it is // only way to be noticed the a dialog form was closed // If we're not supposed to dispose the form, we need to listen // for the closing event instead, as the form will already be disposed // by the time Closed is raised. if (disposeForm) { form.Closed += new EventHandler(ModalForm_Closed); } else { form.Closing += new System.ComponentModel.CancelEventHandler(ModalForm_Closing); } form.Show(); form.Capture = true; IntPtr hwnd = Win32Window.GetCapture(); form.Capture = false; ThreadWindows previousThreadWindows = threadWindows; threadWindows = new ThreadWindows(hwnd); threadWindows.previousThreadWindows = previousThreadWindows; threadWindows.Enable(false); // enters dialog window loop LocalModalMessageLoop(); result = form.DialogResult; if (threadWindows != null) { threadWindows = threadWindows.previousThreadWindows; } if (disposeForm) { form.Closed -= new EventHandler(ModalForm_Closed); form.Dispose(); } else { form.Closing -= new System.ComponentModel.CancelEventHandler(ModalForm_Closing); } if (NativeMethods.IsWindow(lastWnd) && NativeMethods.IsWindowVisible(lastWnd)) { NativeMethods.SetActiveWindow(lastWnd); } #endif return(result); }
/// <summary> /// Resumes painting the <see cref="ComboBoxEx"/> control after painting is suspended by the <see cref="BeginUpdate"/> method. /// <para><b>New in v1.3</b></para> /// </summary> public void EndUpdate() { m_updatable = true; Win32Window.SendMessage(this.Handle, (int)WM.SETREDRAW, 1, 0); }
/// <summary> /// Control is subclassed by substituting the GWL_WNDPROC DWORD with a pointer to /// our replacement window proc /// </summary> private void Subclass() { newWndProc = new WndProcDelegate(WndProc); prevWndProc = (IntPtr)Win32Window.GetWindowLong(Handle, GWL.WNDPROC); Win32Window.SetWindowLong(Handle, GWL.WNDPROC, Marshal.GetFunctionPointerForDelegate(newWndProc)); }
/// <summary> /// Maintains performance when items are added to the <see cref="ComboBoxEx"/> one at a time. /// <para><b>New in v1.3</b></para> /// </summary> public void BeginUpdate() { m_updatable = false; Win32Window.SendMessage(this.Handle, (int)WM.SETREDRAW, 0, 0); }
//When the parent control is resized, the hosted needs to be resized as well // We emulate dock.fill behavior protected override void OnResize(EventArgs e) { base.OnResize(e); Win32Window.SetWindowPos(m_hwndControl, 0, 0, 0, ClientRectangle.Width, ClientRectangle.Height, SWP.NOZORDER); }