public void Move(int x, int y, int w, int h) { if (!User32Native.MoveWindow(Handle, x, y, w, h, true)) { throw Win32Exc.FromLastError(); } }
public void Scroll(int dx, int dy) { if (User32Native.ScrollWindowEx(Handle, dx, dy, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, SW_INVALIDATE) == -1) { throw Win32Exc.FromLastError(); } }
public int GetProcessId(out int threadId) { threadId = User32Native.GetWindowThreadProcessId(Handle, out var processId); if (threadId == 0) { throw Win32Exc.FromLastError(); } return(processId); }
public RECT GetRect() { var rect = default(RECT); if (!User32Native.GetWindowRect(Handle, ref rect)) { throw Win32Exc.FromLastError(); } return(rect); }
public void Disable() { if (!Enabled) { throw new InvalidOperationException(); } if (!User32Native.UnregisterHotKey(Form.Handle, GlobalAtomId)) { throw Win32Exc.FromLastError(); } }
public void Enable(Keys hotkey, Func <bool> callback) { callback.AssertNotNull(nameof(callback)); if (Enabled) { throw new InvalidOperationException(); } var modifiers = GetFsModifiers(hotkey, out var keysModifiers); var keys = (int)hotkey & ~(int)keysModifiers; if (!User32Native.RegisterHotKey(Form.Handle, GlobalAtomId, (uint)modifiers, (uint)keys)) { throw Win32Exc.FromLastError(); } Callback = callback; Enabled = true; }