/// <inheritdoc/> public void SetWindowPos(IntPtr hwnd, Rect position, SwpType uFlags) { if (!SetWindowPos(hwnd, IntPtr.Zero, position.Left, position.Top, position.Right, position.Bottom, uFlags)) { HResult.ThrowLastError(); } }
/// <inheritdoc/> public void RedrawMenuBar(IntPtr hwnd) { if (!DrawMenuBar(hwnd)) { HResult.ThrowLastError(); } }
/// <inheritdoc/> public List <Monitor> GetAllMonitors() { var monitors = new List <Monitor>(); bool Callback(IntPtr hMonitor, IntPtr hdc, ref Rect lpRect, IntPtr dwData) { var monitor = new Monitor { Size = 40, // We harcode the value as Marshal.SizeOf returns a invalid value as our struct contains extra data (40 = MONITORINFO , 72 = MONITORINFOEX) MonitorHandle = hMonitor }; if (!GetMonitorInfo(hMonitor, ref monitor)) { HResult.ThrowLastError(); } monitors.Add(monitor); return(true); } EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, Callback, IntPtr.Zero); return(monitors); }
/// <inheritdoc/> public Rect GetWindowRect(IntPtr hwnd) { if (!GetWindowRect(hwnd, out var rect)) { HResult.ThrowLastError(); } return(rect); }
/// <inheritdoc/> public IntPtr GetWindowLongPtr(IntPtr hwnd, GwlType nIndex) { IntPtr returnValue; if (IntPtr.Size == 8) { // 64 bit system returnValue = GetWindowLongPtr64(hwnd, nIndex); } else { // 32 bit system returnValue = GetWindowLongPtr32(hwnd, nIndex); } if (returnValue == IntPtr.Zero) { HResult.ThrowLastError(); } return(returnValue); }
/// <inheritdoc/> public IntPtr SetWindowLongPtr(IntPtr hwnd, GwlType nIndex, IntPtr dwNewLong) { IntPtr returnValue; if (IntPtr.Size == 8) { // 64 bit system returnValue = SetWindowLongPtr64(hwnd, nIndex, dwNewLong); } else { // 32 bit system returnValue = (IntPtr)SetWindowLongPtr32(hwnd, nIndex, dwNewLong.ToInt32()); } if (returnValue == IntPtr.Zero) { HResult.ThrowLastError(); } return(returnValue); }