函數功能描述:用這個函數能夠獲得指定視窗的資訊
函數原型:
LONG GetWindowLong( HWND hWnd,int nIndex )
參數:
hWnd:指定視窗的控制代碼
nIndex:需要獲得的資訊的類型
值 功能
nIndex取值如下:
GWL_EXSTYLE 得到擴充的視窗風格
GWL_STYLE 得到視窗風格
GWL_WNDPROC 得到視窗回呼函數的地址,或者控制代碼。得到後必須使用CallWindowProc函數來調用
GWL_HINSTANCE 得到應用程式運行執行個體的控制代碼
GWL_HWNDPARENT 得到父視窗的控制代碼
GWL_ID 得到視窗的標識符
GWL_USERDATA 得到和視窗相關聯的32位的值(每一個視窗都有一個有意留給建立視窗的應用程式是用的32位
的值)
當hWnd標識一個對話方塊時可以使用下面的值
Value Action
DWL_DLGPROC 得到對話方塊回呼函數的地址,或者控制代碼。得到後必須使用CallWindowProc函數來調用
DWL_MSGRESULT 得到對話方塊回呼函數中訊息處理過程的傳回值
DWL_USER 得到額外的應用程式私人資訊,如一些控制代碼和指標等
傳回值:
成功時,返回一個請求的32位的值
失敗時,返回0,可以使用GetLastError來取得錯誤資訊
MSDN的原文:
GetWindowLong
The GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window.
LONG GetWindowLong( HWND hWnd, // handle of window int nIndex // offset of value to retrieve);
Parameters
-
hWnd
-
Handle to the window and, indirectly, the class to which the window belongs.
-
nIndex
-
Specifies the zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To retrieve any other value, specify one of the following values:
| Value |
Action |
| GWL_EXSTYLE |
Retrieves the extended window styles. |
| GWL_STYLE |
Retrieves the window styles. |
| GWL_WNDPROC |
Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. |
| GWL_HINSTANCE |
Retrieves the handle of the application instance. |
| GWL_HWNDPARENT |
Retrieves the handle of the parent window, if any. |
| GWL_ID |
Retrieves the identifier of the window. |
| GWL_USERDATA |
Retrieves the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window. |
The following values are also available when the hWnd parameter identifies a dialog box:
| Value |
Action |
| DWL_DLGPROC |
Retrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure. |
| DWL_MSGRESULT |
Retrieves the return value of a message processed in the dialog box procedure. |
| DWL_USER |
Retrieves extra information private to the application, such as handles or pointers. |
Return Values
If the function succeeds, the return value is the requested 32-bit value.
If the function fails, the return value is zero. To get extended error information, callGetLastError.