Exemplo n.º 1
0
        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;
                    }
                }
            }
        }