Esempio n. 1
0
 /// <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();
     }
 }
Esempio n. 2
0
 /// <inheritdoc/>
 public void RedrawMenuBar(IntPtr hwnd)
 {
     if (!DrawMenuBar(hwnd))
     {
         HResult.ThrowLastError();
     }
 }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
 /// <inheritdoc/>
 public Rect GetWindowRect(IntPtr hwnd)
 {
     if (!GetWindowRect(hwnd, out var rect))
     {
         HResult.ThrowLastError();
     }
     return(rect);
 }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        /// <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);
        }