GetWindowRect

GetWindowRect

GetWindowRect是一個Windows API函數。該函數返回指定窗口的邊框矩形的尺寸,函數原型為void GetWindowRect(LPRECT lpRect) const。

函數功能


該函數返回指定窗口的邊框矩形的尺寸。該尺寸以相對於屏幕坐標左上角的屏幕坐標給出。

函數原型


BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);
Visual Studio 2005中,函數原型為void GetWindowRect(LPRECT lpRect) const;
是屬於CWnd類的函數.

參數


hWnd:窗口句柄。
lpRect:指向一個RECT結構的指針,該結構接收窗口的左上角和右下角的屏幕坐標。

變數


left ;top; right;bottom;
分別表示該窗口的/左側/頂部/右側/底部坐標

返回值


如果函數成功,返回值為非零:如果函數失敗,返回值為零。若想獲得更多錯誤信息,請調用GetLastError函數。

速查


Windows NT:3.1以上版本:Windows:95以上版本;Windows CE:1.0以上版本;頭文件:Windows.h;庫文件:User32.lib。

聲明


VB.NET 聲明
Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer
Private Structure RECT
Dim left As Integer
Dim top As Integer
Dim right As Integer
Dim bottom As Integer
End Structure