bool OnParentWmPaint(ref Message m, BaseWndProc baseProc) { IntPtr hwnd = m.HWnd; var clientRect = new NativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(hwnd, ref clientRect); ActionOnFrameRect(clientRect.ToRectangle(), rect => UnsafeNativeMethods.ValidateRect(hwnd, ref rect)); return(false); }
bool OnParentWmNcCalcSize(ref Message m, BaseWndProc baseProc) { if (m.WParam != IntPtr.Zero) { m.Result = IntPtr.Zero; ExtendFrameIntoClientArea(m.HWnd); return(true); } return(false); }
bool OnParentWmEraseBackground(ref Message m, BaseWndProc baseProc) { baseProc(ref m); using (var g = Graphics.FromHdc(m.WParam)) { DrawParentFrame(g, m.HWnd); } return(true); }
bool OnParentWmNcHitTest(ref Message m, BaseWndProc baseProc) { int hitTestCode = GetHitTest(m); if (hitTestCode != NativeMethods.HTNOWHERE) { m.Result = (IntPtr)hitTestCode; return(true); } return(false); }
bool OnParentWmNcRButtonUp(ref Message m, BaseWndProc baseProc) { switch (m.WParam.ToInt32()) { case NativeMethods.HTCAPTION: case NativeMethods.HTSYSMENU: // HACK: display a system menu UnsafeNativeMethods.PostMessage(m.HWnd, 0x313, IntPtr.Zero, m.LParam); return(true); } return(false); }
bool OnParentWmSize(ref Message m, BaseWndProc baseProc) { var oldRect = this.ParentForm.ClientRectangle; baseProc(ref m); IntPtr hwnd = m.HWnd; var newRect = new NativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(hwnd, ref newRect); ActionOnFrameRect(oldRect, rect => UnsafeNativeMethods.InvalidateRect(hwnd, ref rect, 1)); ActionOnFrameRect(newRect.ToRectangle(), rect => UnsafeNativeMethods.InvalidateRect(hwnd, ref rect, 1)); return(true); }
bool OnParentWmWindowPosChanged(ref Message m, BaseWndProc baseProc) { if (this.ParentForm == null || this.ParentForm.IsHandleCreated == false) { return(false); } // recover the correct size of the parent window // after the Form's WM_WINDOWPOSCHANGED handler messes it up. // 1a. minimise FormWindowState.Normal, SW_SHOWMINIMIZED // 1b. maximise FormWindowState.Maximized, SW_SHOWMAXIMIZED // 2. restore (ignore) FormWindowState.Minimized, SW_SHOWMINIMIZED // 3. reentrant (<<here) FormWindowState.Normal, SW_SHOWNORMAL var parentForm = this.ParentForm; var wp = new NativeMethods.WINDOWPLACEMENT(); wp.length = Marshal.SizeOf(typeof(NativeMethods.WINDOWPLACEMENT)); UnsafeNativeMethods.GetWindowPlacement(this.ParentForm.Handle, ref wp); var saveSize = (wp.showCmd == NativeMethods.SW_SHOWMINIMIZED) || (wp.showCmd == NativeMethods.SW_SHOWMAXIMIZED); if (saveSize) { this.restoredWindowSize = wp.rcNormalPosition.ToRectangle().Size; this.restoredSizeSaved = true; } var stage2 = parentForm.WindowState == FormWindowState.Minimized && wp.showCmd == NativeMethods.SW_SHOWMINIMIZED; var stage3 = parentForm.WindowState == FormWindowState.Normal && wp.showCmd == NativeMethods.SW_SHOWNORMAL; baseProc(ref m); if (this.restoredSizeSaved && stage3) { this.restoredSizeSaved = false; //parentForm.Refresh(); parentForm.Size = this.restoredWindowSize; } else if (stage2) { } return(true); }
bool OnParentWmDwmCompositionChanged(ref Message m, BaseWndProc baseProc) { ExtendFrameIntoClientArea(m.HWnd); return(false); }
bool OnParentWmActivate(ref Message m, BaseWndProc baseProc) { UpdateForeColour(m.WParam.ToInt32() != NativeMethods.WA_INACTIVE); this.Refresh(); return(false); }