Exemplo n.º 1
0
            /// <summary>
            /// Wraps <see cref="User32Dll.GetWindowRect"/>.
            /// </summary>
            public static Rectangle GetWindowRect(IntPtr hwnd)
            {
                RECT rc;

                if (User32Dll.GetWindowRect((void *)hwnd, &rc) == 0)
                {
                    throw new Win32Exception();
                }
                return(rc);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Wraps the <see cref="User32Dll.SetLayeredWindowAttributes"/> calls.
            /// </summary>
            public static bool SetLayeredWindowAttributes([NotNull] IWin32Window window, Color colorkey, double alpha, SetLayeredWindowAttributesFlags flags)
            {
                if (window == null)
                {
                    throw new ArgumentNullException("window");
                }
                if ((alpha < 0) || (alpha > 1))
                {
                    throw new ArgumentOutOfRangeException("alpha", alpha, "The alpha value must be in the [0…1] range.");
                }

                return(User32Dll.SetLayeredWindowAttributes((void *)window.Handle, unchecked ((uint)colorkey.ToArgb()), (byte)(alpha * 0xFF), (uint)flags) != 0);
            }
Exemplo n.º 3
0
            /// <summary>
            /// Invalidates the specific rectangle. If <paramref name="rect"/> is <c>Null</c>, the whole window is invalidated.
            /// </summary>
            public static bool InvalidateRect(IntPtr hWnd, Rectangle?rect, bool erase)
            {
                if (hWnd == IntPtr.Zero)
                {
                    return(false);
                }

                if (rect == null)                // Full area
                {
                    return(User32Dll.InvalidateRect((void *)hWnd, null, erase ? 1 : 0) != 0);
                }

                RECT rc = (Rectangle)rect;

                return(User32Dll.InvalidateRect((void *)hWnd, &rc, erase ? 1 : 0) != 0);
            }
Exemplo n.º 4
0
 /// <summary>
 /// The ShowWindow function sets the specified window's show state.
 /// </summary>
 public static bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow)
 {
     return(User32Dll.ShowWindow((void *)hWnd, (int)nCmdShow) != 0);
 }
Exemplo n.º 5
0
 /// <summary>
 /// The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
 /// To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessageW or PostThreadMessage function.
 /// </summary>
 public static IntPtr SendMessageW(IntPtr hWnd, WindowsMessages msg, IntPtr wParam, IntPtr lParam)
 {
     return(User32Dll.SendMessageW((void *)hWnd, (uint)msg, wParam, lParam));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Calls <see cref="User32Dll.DestroyWindow"/>.
 /// </summary>
 public static bool DestroyWindow(IntPtr hwnd)
 {
     return(User32Dll.DestroyWindow((void *)hwnd) != 0);
 }