示例#1
0
        protected override void FilterMessage(object sender, FilterMessageEventArgs e)
        {
            e.Handled = false;

            if (Manager == null)
            {
                return;
            }

            switch (e.Msg)
            {
            case WM_NCLBUTTONDOWN:     //Left button down on title -> start dragging over docking manager
                if (IsDockableWindow && e.WParam.ToInt32() == HTCAPTION)
                {
                    short x = (short)((e.LParam.ToInt32() & 0xFFFF));
                    short y = (short)((e.LParam.ToInt32() >> 16));

                    Point clickPoint = this.TransformToDeviceDPI(new Point(x, y));
                    Manager.Drag(this, clickPoint, new Point(clickPoint.X - Left, clickPoint.Y - Top));

                    e.Handled = true;
                }
                break;

            case WM_NCLBUTTONDBLCLK:     //Left Button Double Click -> dock to docking manager
                if (IsDockableWindow && e.WParam.ToInt32() == HTCAPTION)
                {
                    if (IsDockableWindow)
                    {
                        Dock();
                        e.Handled = true;
                    }
                }
                break;
            }



            base.FilterMessage(sender, e);
        }
示例#2
0
        protected virtual void FilterMessage(object sender, FilterMessageEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            if (Manager == null)
            {
                return;
            }

            switch (e.Msg)
            {
            case WM_SIZE:
            case WM_MOVE:
                break;

            case WM_NCRBUTTONDOWN:     //Right button click on title area -> show context menu
                if (e.WParam.ToInt32() == HTCAPTION)
                {
                    short x = (short)((e.LParam.ToInt32() & 0xFFFF));
                    short y = (short)((e.LParam.ToInt32() >> 16));
                    OpenContextMenu(null, new Point(x, y));
                    e.Handled = true;
                }
                break;

            case WM_NCRBUTTONUP:     //set as handled right button click on title area (after showing context menu)
                if (e.WParam.ToInt32() == HTCAPTION)
                {
                    e.Handled = true;
                }
                break;
            }
        }
示例#3
0
        private IntPtr HookHandler(
            IntPtr hwnd,
            int msg,
            IntPtr wParam,
            IntPtr lParam,
            ref bool handled
            )
        {
            handled = false;

            switch (msg)
            {
            case SC_MOVE:
            case WM_WINDOWPOSCHANGING:
                SafeFireEvent <EventArgs>(WindowPosChanging, EventArgs.Empty);
                break;

            case WM_MOUSEACTIVATE:
            {
                CancelEventArgs args = new CancelEventArgs();
                SafeFireEvent <CancelEventArgs>(WindowActivating, args);
                if (args.Cancel)
                {
                    Debug.WriteLine("Cancelled");
                    handled = true;
                    return((IntPtr)MA_NOACTIVATE);
                }
            }
            break;

            case WM_ACTIVATE:
            {
                if (((int)wParam & 0xFFFF) != WA_INACTIVE)
                {
                    CancelEventArgs args = new CancelEventArgs();
                    SafeFireEvent <CancelEventArgs>(WindowActivating, args);
                    if (args.Cancel)
                    {
                        if (lParam != IntPtr.Zero)
                        {
                            SetActiveWindow(lParam);
                        }
                        Debug.WriteLine("Cancelled Activation");
                        handled = true;
                    }
                }
            }
            break;
            }

            if (!handled)
            {
                FilterMessageEventArgs e = new FilterMessageEventArgs(
                    hwnd,
                    msg,
                    wParam,
                    lParam);

                SafeFireEvent <FilterMessageEventArgs>(FilterMessage, e);

                handled = e.Handled;
            }

            return(IntPtr.Zero);
        }