示例#1
0
        LRESULT WndProc(HWND hwnd, WM msg, WPARAM wParam, LPARAM lParam)
        {
            switch (msg)
            {
            case WM.CLOSE:
                OnClose?.Invoke();
                if (DestroyWhenClose == null || DestroyWhenClose())
                {
                    User32.DestroyWindow(hwnd);
                }
                return(0);

            case WM.ENABLE:
                OnEnable?.Invoke(wParam);
                break;

            case WM.SHOWWINDOW:
                OnShow?.Invoke(wParam);
                break;

            case WM.DESTROY:
                OnDestroy?.Invoke();
                return(0);

            case WM.MOUSEMOVE:
                OnMouseMove?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.LBUTTONDOWN:
                OnMouseLeftDown?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.LBUTTONUP:
                OnMouseLeftUp?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.LBUTTONDBLCLK:
                OnMouseLeftDoubleClicked?.Invoke();
                return(0);

            case WM.RBUTTONDOWN:
                OnMouseRightDown?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.RBUTTONUP:
                OnMouseRightUp?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.MBUTTONDOWN:
                OnMouseMiddleDown?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.MBUTTONUP:
                OnMouseMiddleUp?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.MOUSEWHEEL:
                OnMouseWheel?.Invoke(wParam.HiWord);
                return(0);

            case WM.RESIZE:
                OnResize?.Invoke(lParam.LowWord, lParam.HiWord);
                return(0);

            case WM.PAINT:
            {
                var ps = default(PAINTSTRUCT);
                User32.BeginPaint(hwnd, ref ps);
                OnPaint?.Invoke();
                User32.EndPaint(hwnd, ref ps);
            }
                return(0);
            }
            return(User32.DefWindowProcW(hwnd, msg, wParam, lParam));
        }
示例#2
0
 internal void CallMouseMiddleUp()
 {
     IsMouseMiddlePressed = false;
     OnMouseMiddleUp?.Invoke();
 }