Пример #1
0
        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;
                }
            }
        }
Пример #2
0
        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;
            }
        }