/// <summary> /// Clients to screen. /// </summary> /// <param name="handle">A handle.</param> /// <param name="point">A point.</param> /// <returns></returns> public static POINT ClientToScreen(WindowHandle handle, POINT point) { POINT point1 = point; if (!ClientToScreen(handle, ref point1)) { throw new Win32Exception(); } return point1; }
/// <summary> /// Gets the window rect. /// </summary> /// <param name="handle">A handle.</param> /// <returns></returns> public static RECT GetWindowRect(WindowHandle handle) { RECT rect1 = RECT.Empty; if (!GetWindowRect(handle, ref rect1)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } return rect1; }
public static extern IntPtr GetWindowDC(WindowHandle window);
public static extern WindowHandle GetParent(WindowHandle hWnd);
/// <summary> /// Initializes a new instance of the <see cref="Window"/> class. /// </summary> /// <param name="handle">The handle.</param> public Window(WindowHandle handle) { this._Handle = handle; }
public static extern bool MoveWindow(WindowHandle handle, int x, int y, int width, int height, [MarshalAs(UnmanagedType.Bool)] bool repaint);
private static extern bool ScreenToClient(WindowHandle handle, ref POINT point);
/// <summary> /// retrieves a handle to a window whose class name and window name match the specified strings. /// </summary> /// <param name="parent">parent window whose child windows are to be searched.</param> /// <param name="childAfter">The child after.</param> /// <param name="className">specifies the class name or a class atom.</param> /// <param name="windowName">specifies the window name (the window title).</param> /// <returns>If the function succeeds, the return value is a handle to the window that has /// the specified class and window names. /// If the function fails, the return value is NULL. /// </returns> public static WindowHandle FindWindow(WindowHandle parent, WindowHandle childAfter, string className, string windowName) { IntPtr ptr1 = IntPtr.Zero; IntPtr ptr2 = IntPtr.Zero; if (!String.IsNullOrEmpty(className)) { ptr1 = Marshal.StringToHGlobalAuto(className); } while (true) { if (!String.IsNullOrEmpty(windowName)) { ptr2 = Marshal.StringToHGlobalAuto(windowName); } try { return FindWindow(parent, childAfter, ptr1, ptr2); } finally { if (ptr1 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr1); } if (ptr2 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr2); } } } }
/// <summary> /// retrieves a handle to a window whose class name and window name match the specified strings. /// </summary> /// <param name="parent">parent window whose child windows are to be searched.</param> /// <param name="childAfter">The child after.</param> /// <param name="className">specifies the class name or a class atom.</param> /// <param name="windowName">specifies the window name (the window title).</param> /// <returns>If the function succeeds, the return value is a handle to the window that has /// the specified class and window names. /// If the function fails, the return value is NULL. /// </returns> public static WindowHandle FindWindow(IWin32Window parent, WindowHandle childAfter, string className, string windowName) { return FindWindow(parent.Handle, childAfter, className, windowName); }
/// <summary> /// Clients to screen. /// </summary> /// <param name="clientHandle">A client handle.</param> /// <returns></returns> public POINT ClientToScreen(WindowHandle clientHandle) { return UnsafeNativeMethods.ClientToScreen(clientHandle, this); }
/// <summary> /// Screens to client. /// </summary> /// <param name="clientHandle">A client handle.</param> /// <returns></returns> public POINT ScreenToClient(WindowHandle clientHandle) { return UnsafeNativeMethods.ScreenToClient(clientHandle, this); }
/// <summary> /// Equalses the specified WindowHandle. /// </summary> /// <param name="hwnd">The WindowHandle.</param> /// <returns></returns> public bool Equals(WindowHandle hwnd) { return this.Equals(hwnd.Handle); }
/// <summary> /// Initializes a new instance of the <see cref="Window"/> class. /// </summary> /// <param name="window">The window.</param> public Window(IWin32Window window) { if (window == null) { throw new ArgumentNullException("window"); } this._Handle = new WindowHandle(window); }
/// <summary> /// Initializes a new instance of the <see cref="Window"/> class. /// </summary> /// <param name="value">The value.</param> public Window(IntPtr value) { this._Handle = new WindowHandle(value); }
public static extern bool GetWindowRect(WindowHandle handle, [In, Out] ref RECT rect);
/// <summary> /// retrieves the name of the class to which the specified window belongs. /// </summary> /// <param name="handle">The handle.</param> /// <returns>class name of specified window</returns> public static string GetClassName(WindowHandle handle) { StringBuilder builder1 = new StringBuilder(0x100); int num1 = GetClassName(handle, builder1, 0x100); return builder1.ToString(0, num1); }
/// <summary> /// determines whether the specified window handle identifies an existing window. /// </summary> /// <param name="hWnd"> Handle to the window to test.</param> /// <returns>If the window handle identifies an existing window, the return value is true.</returns> public static bool IsWindow(WindowHandle hWnd) { if (hWnd == WindowHandle.Empty) { return false; } return IsWindow(hWnd.Handle); }
public static extern WindowHandle GetDlgItem(WindowHandle hWnd, int dlgItem);
private static extern bool ClientToScreen(WindowHandle handle, ref POINT point);
/// <summary> /// retrieves the handle to a control in the specified dialog box. /// </summary> /// <param name="hWnd">Handle to the dialog box that contains the control.</param> /// <param name="dlgItem">Specifies the identifier of the control to be retrieved.</param> /// <returns>The window handle of the specified control indicates success. NULL indicates /// failure due to an invalid dialog box handle or a nonexistent control.</returns> public static WindowHandle GetDlgItem(WindowHandle hWnd, MessageBoxItem dlgItem) { return GetDlgItem(hWnd, (int)dlgItem); }
/// <summary> /// retrieves a handle to a window whose class name match the specified strings. /// </summary> /// <param name="parent">parent window whose child windows are to be searched.</param> /// <param name="childAfter">The child after.</param> /// <param name="className">specifies the class name or a class atom.</param> /// <returns>If the function succeeds, the return value is a handle to the window that has /// the specified class and window names. /// If the function fails, the return value is NULL. /// </returns> public static WindowHandle FindWindow(WindowHandle parent, IWin32Window childAfter, string className) { return FindWindow(parent, childAfter.Handle, className, null); }
/// <summary> /// Initializes a new instance of the <see cref="Window"/> class. /// </summary> /// <param name="value">The value.</param> public Window(int value) { this._Handle = new WindowHandle(value); }