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); }
void DrawParentFrame(Graphics g, IntPtr hwnd) { var rect = new NativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(hwnd, ref rect); var frameRect = rect.ToRectangle(); frameRect.Width--; frameRect.Height--; using (var pen = new Pen(this.BackColor)) { g.DrawRectangle(pen, frameRect); } }
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); }