GetClassLong Function

Declare Function GetClassLong Lib "user32.dll" Alias "GetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Platforms

Description & Usage

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.

Return Value

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.

Visual Basic-Specific Issues

None.

Parameters

hWnd
A handle to a window which belongs to the class to read a property of.
nIndex
To retrieve a 32-bit value from the class's extra memory, set this to the zero-based offset of the byte to begin reading at. Valid values are 0 to the number of bytes of extra memory minus 4, inclusive. To retrieve a 32-bit property of the class, set this to one of the following flags specifying which 32-bit value to retrieve from the window class:
GCW_ATOM
Retrieve the atom which identifies the window class.
GCL_CBCLSEXTRA
Retrieve the size in bytes of the extra memory associated with the window class.
GCL_CBWNDEXTRA
Retrieve the size in bytes of the extra memory associated with each window belonging to the window class.
GCL_HBRBACKGROUND
Retrieve a handle to the brush used to paint the backgrounds of windows belonging to the class.
GCL_HCURSOR
Retrieve a handle to the cursor associated with the class.
GCL_HICON
Retrieve a handle to the icon associated with the class.
GCL_HICONSM
Retrieve a handle to the small icon associated with the class.
GCL_HMODULE
Retrieve a handle to the module which registered the class.
GCL_MENUNAME
Retrieve a pointer to the string identifying the name of the menu resource associated with the class.
GCL_STYLE
Retrieve the window styles associated with the class.
GCL_WNDPROC
Retrieve a pointer to the WindowProc hook function which acts as the window procedure for windows belonging to the window class.

Constant Definitions

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

Example

' Draw the icon associated with whatever class window Form1
' belongs to.  Draw the icon on Form1.  This icon is not necessarily the
' same icon which Form1 uses, but it can be.
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(Form1.hWnd, GWL_HICON)  ' this gets the class's icon, not the window's
' Draw that icon at coordinate (0,0) on Form1.
retval = DrawIcon(Form1.hDC, 0, 0, hIcon)

Related Functions

GetWindowLong, SetClassLong

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/getclasslong.html