Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
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.
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.
None.
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
When the user clicks button Command1, determine if its parent window has a maximize button or not by checking its window style. To use this example, you must first place a command button named Command1 on a form window.
' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, _ ByVal nIndex As Long) As Long Public Const GWL_STYLE = -16 Public Const WS_MAXIMIZEBOX = &H10000 ' *** Place the following code inside a form window. *** Private Sub Command1_Click () Dim styles As Long ' receives window styles of Form1 ' Get the window styles of Form1. styles = GetWindowLong(Me.hWnd, GWL_STYLE) ' Determine if a maximize box exists or not. If (styles And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then Debug.Print "The form window has a maximize box." Else Debug.Print "The form window does not have a maximize box." End If End Sub
GetClassLong, SetWindowLong
Window Classes
Go back to the alphabetical Function listing.
Go back to the Reference section index.
Last Modified: October 29, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getwindowlong.html