protected virtual void OnFrameHitTest(FrameHitTestEventArgs e) { var handler = Events[EventFrameHitTest] as EventHandler <FrameHitTestEventArgs>; if (handler != null) { handler(this, e); } }
protected override void WndProc(ref Message m) { if (m.Msg == WindowMessages.WM_DWMCOMPOSITIONCHANGED) { if (DesktopComposition.IsEnabled) { ExtendFrameIntoClientArea(); } _owner.OnCompositionChanged(EventArgs.Empty); } if (m.Msg == WindowMessages.WM_DWMCOLORIZATIONCOLORCHANGED) { _owner.OnColorizationChanged(EventArgs.Empty); } if (DesktopComposition.IsEnabled) { if (m.Msg == WindowMessages.WM_ACTIVATE) { // // MSDN recommends to do this on WM_ACTIVATE to correctly support // maximized windows. // http://msdn2.microsoft.com/library/bb688195.aspx // ExtendFrameIntoClientArea(); } if (_form.CustomFrame) { if ((m.Msg == WindowMessages.WM_NCCALCSIZE) && (m.WParam.ToInt32() == 1)) { // // tell DWM we'll draw our own frame // m.Result = IntPtr.Zero; return; } else if (m.Msg == WindowMessages.WM_NCHITTEST) { IntPtr result; if (!NativeMethods.DwmDefWindowProc(GetHandleRef(), m.Msg, m.WParam, m.LParam, out result)) { // // we must do the hit testing ourselves // var pt = new Point(m.LParam.ToInt32()); var e = new FrameHitTestEventArgs(_form.Form, pt); _owner.OnFrameHitTest(e); if (!e.IsAssigned) { e.Result = DefaultHitTest(_form, pt); } result = new IntPtr((Int32)(e.Result)); } m.Result = result; return; } } } base.WndProc(ref m); }