Declare Function GetClassLong Lib "user32.dll" Alias "GetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
GetClassLong retrieves a single 32-bit value from the information about the window class to which the specified window belongs. The class's properties may not necessarily match perfectly with the actual properties of the window. This function can also retrieve a 32-bit value from the extra memory area associated with the window class.
If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns the desired 32-bit value.
None.
Const GCW_ATOM = -32
Const GCL_CBCLSEXTRA = -20
Const GCL_CBWNDEXTRA = -18
Const GCL_HBRBACKGROUND = -10
Const GCL_HCURSOR = -12
Const GCL_HICON = -14
Const GCL_HMODULE = -16
Const GCL_MENUNAME = -8
Const GCL_STYLE = -26
Const GCL_WNDPROC = -24
When the user clicks button Command1, draw the icon associated with the parent form window's class in the corner of the client area. This might not be the icon actually displayed by the window. Naturally, to use this exampe, 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 GetClassLong Lib "user32.dll" Alias "GetClassLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Public Const GCL_HICON = -14
Public Declare Function DrawIcon Lib "user32.dll" (ByVal hDC As Long, ByVal x As Long, ByVal y _
As Long, ByVal hIcon As Long) As Long
' Place the following code inside a form window. ***
Private Sub Command1_Click ()
Dim hIcon As Long ' handle to the class's icon
Dim retval As Long ' return value
' Retrieve a handle to the class's icon.
hIcon = GetClassLong(Me.hWnd, GCL_HICON)
' Draw that icon at coordinate (0,0) on Form1.
retval = DrawIcon(Me.hDC, 0, 0, hIcon)
End Sub
Go back to the 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/getclasslong.html