Esempio n. 1
0
        private IntPtr HwndSourceHookHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_MOVING    = 0x0216;
            const int WM_LBUTTONUP = 0x0202;

            switch (msg)
            {
            case WM_LBUTTONUP:
                ((MainWindow)Application.Current.MainWindow).CancelSplitBgWorker();
                break;

            case WM_MOVING:
            {
                MoveRectangle rectangle = (MoveRectangle)Marshal.PtrToStructure(lParam, typeof(MoveRectangle));
                if (!FoldFlag)
                {
                    if (rectangle.Right > scr.Width - 5)
                    {
                        NeedHide        = true;
                        rectangle.Left  = scr.Width - (int)Width;
                        rectangle.Right = scr.Width;
                    }
                    else
                    {
                        NeedHide = false;
                        if (rectangle.Left < 0)
                        {
                            rectangle.Left  = 0;
                            rectangle.Right = (int)Width;
                        }
                    }
                    if (rectangle.Bottom > scr.Height)
                    {
                        rectangle.Top    = scr.Height - (int)Height;
                        rectangle.Bottom = scr.Height;
                    }
                    else if (rectangle.Top < 0)
                    {
                        rectangle.Top    = 0;
                        rectangle.Bottom = (int)Height;
                    }
                }
                Marshal.StructureToPtr(rectangle, lParam, true);
                break;
            }
            }
            return(IntPtr.Zero);
        }
Esempio n. 2
0
        private IntPtr HwndSourceHookHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_MOVING = 0x0216;

            switch (msg)
            {
            case WM_MOVING:
            {
                MoveRectangle            rectangle = (MoveRectangle)Marshal.PtrToStructure(lParam, typeof(MoveRectangle));
                System.Drawing.Rectangle scr       = System.Windows.Forms.Screen.AllScreens[0].WorkingArea;
                if (rectangle.Right > scr.Width)
                {
                    rectangle.Left  = scr.Width - (int)Width;
                    rectangle.Right = scr.Width;
                }
                else if (rectangle.Left < 0)
                {
                    rectangle.Left  = 0;
                    rectangle.Right = (int)Width;
                }
                if (rectangle.Bottom > scr.Height)
                {
                    rectangle.Top    = scr.Height - (int)Height;
                    rectangle.Bottom = scr.Height;
                }
                else if (rectangle.Top < 0)
                {
                    rectangle.Top    = 0;
                    rectangle.Bottom = (int)Height;
                }
                Marshal.StructureToPtr(rectangle, lParam, true);
                break;
            }
            }
            return(IntPtr.Zero);
        }
Esempio n. 3
0
 internal bool IsMouseHover(MouseEventArgs e)
 {
     return(MoveRectangle.Contains(e.Location));
 }