GetWindowLong Function
Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Platforms
- Windows 95: Supported.
- Windows 98: Supported.
- Windows NT: Requires Windows NT 3.1 or later.
- Windows 2000: Supported.
- Windows CE: Requires Windows CE 1.0 or later.
Description & Usage
GetWindowLong retrieves a 32-bit value from the information about a window. This function can also read a 32-bit value from the block of extra memory given to the window, if one exists.
Return Value
If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns the 32-bit value which was retrieved.
Visual Basic-Specific Issues
None.
Parameters
- hWnd
- A handle to the window to retrieve a 32-bit value from.
- nIndex
- To get a 32-bit value from the window's extra memory block, this is the zero-based offset of the byte to begin reading from. Valid values range from 0 to the size of the extra memory block in bytes minus four. To get a 32-bit value from the properties of the window, this is one of the following flags specifying which piece of information to retieve:
- GWL_EXSTYLE
- Retrieve the extended window styles of the window.
- GWL_HINSTANCE
- Retrieve a handle to the owning application's instance.
- GWL_HWNDPARENT
- Retrieve a handle to the parent window, if any.
- GWL_ID
- Retrieve the identifier of the window.
- GWL_USERDATA
- Retrieve the application-defined 32-bit value associated with the window.
- GWL_STYLE
- Retrieve the window styles of the window.
- GWL_WNDPROC
- Retrieve a pointer to the WindowProc hook function acting as the window's procedure.
If the window happens to be a dialog box, this could also be one of the following flags:
- DWL_DLGPROC
- Retrieve a handle to the WindowProc hook function acting as the dialog box procedure.
- DWL_MSGRESULT
- Retrieve the return value of the last message processed by the dialog box.
- DWL_USER
- Retrieve the application-defined 32-bit value associated with the dialog box.
Constant Definitions
Const GWL_EXSTYLE = -20
Const GWL_HINSTANCE = -6
Const GWL_HWNDPARENT = -8
Const GWL_ID = -12
Const GWL_STYLE = -16
Const GWL_USERDATA = -21
Const GWL_WNDPROC = -4
Const DWL_DLGPROC = 4
Const DWL_MSGRESULT = 0
Const DWL_USER = 8
Example
' Determine if window Form1 has a maximize button on its
' tool bar. That information will be part of the window styles.
Dim styles As Long ' receives window styles of Form1
' Get the window styles of Form1.
styles = GetWindowLong(Form1.hWnd, GWL_STYLE)
' Determine if a maximize box exists or not.
If (styles And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then
Debug.Print "Form1 has a maximize box."
Else
Debug.Print "Form1 does not have a maximize box."
End If
Related Functions
GetClassLong, SetWindowLong
Category
Window Classes
Back to the index.
Last Modified: August 28, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information
Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/g/getwindowlong.html