protected override void WndProc(ref Message m) { base.WndProc(ref m); //Shortcut if disabled if (!HandleMouseMove) { return; } //Respond to hit test messages with Caption if mouse on glass: will enable form moving/maximization //as if mouse is on form caption. if (m.Msg == Messaging.WM_NCHITTEST && m.Result.ToInt32() == Messaging.HTCLIENT) { uint lparam = (uint)m.LParam.ToInt32(); ushort x = IntHelpers.LowWord(lparam); ushort y = IntHelpers.HighWord(lparam); //Check if mouse pointer is on glass part of form var clientPoint = this.PointToClient(new Point(x, y)); if (_glassMargins.IsOutsideMargins(clientPoint, ClientSize)) { m.Result = (IntPtr)Messaging.HTCAPTION; return; } } }
protected override void WndProc(ref Message m) { base.WndProc(ref m); if (!HandleMouseOnGlass || !_glassEnabled) { return; } // Respond to hit test messages with Caption if mouse on glass: // this automatically enables form dragging on glass if (m.Msg == (int)WindowMessage.WM_NCHITTEST && m.Result.ToInt32() == (int)HitTest.HTCLIENT) { // Check if mouse pointer is on glass part of form if (_glassFull) { m.Result = (IntPtr)HitTest.HTCAPTION; } else { uint lparam = (uint)m.LParam.ToInt32(); ushort x = IntHelpers.LowWord(lparam); ushort y = IntHelpers.HighWord(lparam); var clientPoint = PointToClient(new System.Drawing.Point(x, y)); /*if (_glassMargins.IsOutside(clientPoint, ClientSize)) { * m.Result = (IntPtr)HitTest.HTCAPTION; * }*/ } } }
protected override void WndProc(ref Message m) { base.WndProc(ref m); //Shortcut if disabled if (!HandleMouseMove) { return; } //Respond to hit test messages with Caption if mouse on glass: will enable form moving/maximization //as if mouse is on form caption. if (m.Msg == Messaging.WM_NCHITTEST && m.Result.ToInt32() == Messaging.HTCLIENT) { uint lparam = (uint)m.LParam.ToInt32(); ushort x = IntHelpers.LowWord(lparam); ushort y = IntHelpers.HighWord(lparam); //Check if mouse pointer is on glass part of form var clientPoint = this.PointToClient(new Point(x, y)); if (_glassMargins.IsOutsideMargins(clientPoint, ClientSize)) { m.Result = (IntPtr)Messaging.HTCAPTION; return; } } if (m.Msg == WM_DWMCOMPOSITIONCHANGED) { bool compositionEnabled = false; DwmIsCompositionEnabled(ref compositionEnabled); if (Controls.Count == tree.Count) { for (int i = 0; i < Controls.Count; i++) { Controls[i].Location = tree[i]; } } GlassEnabled = compositionEnabled; } }