Example #1
0
 public static IntPtr FindWindow(string lpClassName, string lpWindowName)
 {
     return(User32Methods.FindWindow(lpClassName, lpWindowName));
 }
Example #2
0
 public bool ReleaseDc(IntPtr hdc)
 {
     return(User32Methods.ReleaseDC(this.Handle, hdc));
 }
Example #3
0
 public bool Validate(ref Rectangle rect)
 {
     return(User32Methods.ValidateRect(this.Handle, ref rect));
 }
Example #4
0
 public bool Hide()
 {
     return(User32Methods.ShowWindow(this.Handle, ShowWindowCommands.SW_HIDE));
 }
Example #5
0
 public void EndPaint(ref PaintStruct ps)
 {
     User32Methods.EndPaint(this.Handle, ref ps);
 }
Example #6
0
 public bool IsEnabled()
 {
     return(User32Methods.IsWindowEnabled(this.Handle));
 }
Example #7
0
 public IntPtr GetParam(WindowLongFlags index)
 {
     return(User32Methods.GetWindowLongPtr(this.Handle, (int)index));
 }
Example #8
0
 public bool SetText(string text)
 {
     return(User32Methods.SetWindowText(this.Handle, text));
 }
Example #9
0
 public bool SetPosition(int x, int y)
 {
     return(User32Methods.SetWindowPos(this.Handle, IntPtr.Zero, x, y, -1, -1,
                                       WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_NOSIZE | WindowPositionFlags.SWP_NOZORDER));
 }
Example #10
0
 public bool Invalidate(bool shouldErase = false)
 {
     return(User32Methods.InvalidateRect(this.Handle, IntPtr.Zero, shouldErase));
 }
Example #11
0
 public void SetFocus()
 {
     User32Methods.SetFocus(this.Handle);
 }
Example #12
0
 public bool Invalidate(ref Rectangle rect, bool shouldErase = false)
 {
     return(User32Methods.InvalidateRect(this.Handle, ref rect, shouldErase));
 }
Example #13
0
        public static Rectangle GetWindowRect(IntPtr Hwnd)
        {
            var result = User32Methods.GetWindowRect(Hwnd, out Rectangle win_rectangle);

            return(win_rectangle);
        }
Example #14
0
 public static void SetForegroundWindow(IntPtr Hwnd)
 {
     User32Methods.SetForegroundWindow(Hwnd);
 }
Example #15
0
 public bool GetClientRect(out Rectangle rectangle)
 {
     return(User32Methods.GetClientRect(this.Handle, out rectangle));
 }
Example #16
0
 public bool SetPosition(int x, int y, int width, int height)
 {
     return(User32Methods.SetWindowPos(this.Handle, IntPtr.Zero, x, y, width, height,
                                       WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_NOZORDER));
 }
Example #17
0
 public bool IsVisible()
 {
     return(User32Methods.IsWindowVisible(this.Handle));
 }
Example #18
0
 public bool SetPosition(int x, int y, int width, int height, WindowPositionFlags flags)
 {
     return(User32Methods.SetWindowPos(this.Handle, IntPtr.Zero, x, y, width, height, flags));
 }
Example #19
0
 public IntPtr SetParam(WindowLongFlags index, IntPtr value)
 {
     return(User32Methods.SetWindowLongPtr(this.Handle, (int)index, value));
 }
Example #20
0
 public bool SetPosition(IntPtr hWndInsertAfter, int x, int y, int width, int height, WindowPositionFlags flags)
 {
     return(User32Methods.SetWindowPos(this.Handle, hWndInsertAfter, x, y, width, height, flags));
 }
Example #21
0
 public bool Show()
 {
     return(User32Methods.ShowWindow(this.Handle, ShowWindowCommands.SW_SHOW));
 }
Example #22
0
        private static IntPtr WindowProc(IntPtr hwnd, uint umsg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr result = IntPtr.Zero;

            var msg = (WM)umsg;

            switch (msg)
            {
            case WM.ERASEBKGND:
                return(new IntPtr(1));

            case WM.CLOSE: User32Methods.PostQuitMessage(0);
                break;

            case WM.PAINT:
            {
                var hdc = User32Methods.BeginPaint(hwnd, out PaintStruct ps);
                User32Methods.FillRect(hdc, ref ps.PaintRect,
                                       Gdi32Helpers.GetStockObject(StockObject.WHITE_BRUSH));
                User32Methods.EndPaint(hwnd, ref ps);
                break;
            }

            case WM.KEYDOWN: InputManager.Instance.KeyPressed((VirtualKey)wParam.ToInt32(), lParam.ToInt32() & 0x40000000);
                break;

            case WM.KEYUP: InputManager.Instance.KeyReleased((VirtualKey)wParam.ToInt32());
                break;

            case WM.CHAR: InputManager.Instance.KeyTyped((char)wParam.ToInt32());
                break;

            case WM.MOUSEMOVE:
            {
                int x = unchecked ((short)(long)lParam);
                int y = unchecked ((short)((long)lParam >> 16));
                InputManager.Instance.MouseMoved(x, y);
                break;
            }

            case WM.LBUTTONDOWN:
            {
                int x = unchecked ((short)(long)lParam);
                int y = unchecked ((short)((long)lParam >> 16));
                InputManager.Instance.MousePressed(MouseButton.Left, x, y);
                break;
            }

            case WM.LBUTTONUP:
            {
                int x = unchecked ((short)(long)lParam);
                int y = unchecked ((short)((long)lParam >> 16));
                InputManager.Instance.MouseReleased(MouseButton.Left, x, y);
                break;
            }

            case WM.RBUTTONDOWN:
            {
                int x = unchecked ((short)(long)lParam);
                int y = unchecked ((short)((long)lParam >> 16));
                InputManager.Instance.MousePressed(MouseButton.Right, x, y);
                break;
            }

            case WM.RBUTTONUP:
            {
                int x = unchecked ((short)(long)lParam);
                int y = unchecked ((short)((long)lParam >> 16));
                InputManager.Instance.MouseReleased(MouseButton.Right, x, y);
                break;
            }

            default:
                result = User32Methods.DefWindowProc(hwnd, umsg, wParam, lParam);
                break;
            }
            return(result);
        }
Example #23
0
 public IntPtr BeginPaint(out PaintStruct ps)
 {
     return(User32Methods.BeginPaint(this.Handle, out ps));
 }
Example #24
0
 public void OnTick()
 {
     User32Methods.SetWindowText(m_hWnd, $"{m_Info.Title} | {m_Info.FPS} fps, {m_Info.UPS} ups");
 }
Example #25
0
 public IntPtr GetWindowDc()
 {
     return(User32Methods.GetWindowDC(this.Handle));
 }
Example #26
0
 /// <summary>
 /// The exit.
 /// </summary>
 public static void Exit()
 {
     User32Methods.PostQuitMessage(0);
 }
Example #27
0
 public bool SetState(ShowWindowCommands flags)
 {
     return(User32Methods.ShowWindow(this.Handle, flags));
 }
Example #28
0
 /// <summary>
 /// The close window externally.
 /// </summary>
 public void CloseWindowExternally()
 {
     User32Methods.PostMessage(Handle, (uint)WM.CLOSE, IntPtr.Zero, IntPtr.Zero);
 }
Example #29
0
 public bool Validate()
 {
     return(User32Methods.ValidateRect(this.Handle, IntPtr.Zero));
 }
Example #30
0
 public static void SetMousePos(int x, int y)
 {
     User32Methods.SetPhysicalCursorPos(x, y);
 }