示例#1
0
 /// <summary>
 /// 获取控件的工作区的高度和宽度。
 /// </summary>
 /// <param name="hWnd">控件句柄。</param>
 /// <returns>一个 System.Drawing.Size,表示控件的工作区的维数。</returns>
 public static Size GetClientSize(IntPtr hWnd)
 {
     NativeMethods.RECT lpRect = new NativeMethods.RECT();
     UnsafeNativeMethods.GetClientRect(hWnd, ref lpRect);
     return(lpRect.Size);
 }
示例#2
0
 /// <summary>
 /// 获取表示控件的工作区的矩形。
 /// </summary>
 /// <param name="hWnd">控件句柄。</param>
 /// <returns>一个 System.Drawing.Rectangle,它表示控件的工作区。</returns>
 public static Rectangle GetClientRectangle(IntPtr hWnd)
 {
     NativeMethods.RECT lpRect = new NativeMethods.RECT();
     UnsafeNativeMethods.GetClientRect(hWnd, ref lpRect);
     return(lpRect.ToRectangle());
 }
示例#3
0
 /// <summary>
 /// 计算指定工作区矩形的大小和位置(以屏幕坐标表示)。
 /// </summary>
 /// <param name="hWnd">控件句柄。</param>
 /// <param name="r">要转换的工作区坐标 System.Drawing.Rectangle。</param>
 /// <returns>一个 System.Drawing.Rectangle,它表示转换后的 System.Drawing.Rectangle、r(以屏幕坐标表示)。</returns>
 public static Rectangle RectangleToScreen(IntPtr hWnd, Rectangle r)
 {
     NativeMethods.RECT rect = new NativeMethods.RECT(r);
     UnsafeNativeMethods.MapWindowPoints(hWnd, NativeMethods.HWND_DESKTOP, ref rect, 2);
     return(rect.ToRectangle());
 }