SetClassLong Function

Declare Function SetClassLong Lib "user32.dll" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Platforms

Description & Usage

SetClassLong sets a single 32-bit value from the information about the window class to which the specified window belongs. This function can also set a 32-bit value within 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 previous setting of the 32-bit value which was changed.

Visual Basic-Specific Issues

None.

Parameters

hWnd
A handle to a window which belongs to the class to set a property of.
nIndex
To set a 32-bit value within the class's extra memory, set this to the zero-based offset of the first byte in the 32-bit block to set. Valid values are 0 to the number of bytes of extra memory minus 4, inclusive. To set a 32-bit property of the class, set this to one of the following flags specifying which 32-bit value to set from the window class:
GCL_CBCLSEXTRA
Set the size in bytes of the extra memory associated with the window class. dwNewLong
is the new size of the block.
GCL_CBWNDEXTRA
Set the size in bytes of the extra memory associated with each window belonging to the window class. dwNewLong is the new size of the block.
GCL_HBRBACKGROUND
Set the brush used to paint the backgrounds of windows belonging to the class. dwNewLong is a handle to the brush to use.
GCL_HCURSOR
Set the cursor associated with the class. dwNewLong is a handle to the cursor to use.
GCL_HICON
Set the icon associated with the class. dwNewLong is a handle to the icon to use.
GCL_HICONSM
Set the small icon associated with the class. dwNewLong is a handle to the small icon to use.
GCL_HMODULE
Change the module which registered the class. dwNewLong is a handle to the module to identify as the creator of the class.
GCL_MENUNAME
Set the string identifying the name of the menu resource associated with the class. dwNewLong is a pointer to the new string.
GCL_STYLE
Set the window styles associated with the class. dwNewLong is the new value.
GCL_WNDPROC
Set the WindowProc hook function to use as the window procedure for windows belonging to the window class. dwNewLong is a pointer to the function to use.
dwNewLong
The 32-bit value to set as something.

Constant Definitions

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

' This code is licensed according to the terms and conditions listed here.

' Change the icon associated with whatever class window
' Form1 belongs to.
Dim hIcon As Long  ' handle to the new icon to use
Dim retval As Long  ' return value

' The icon to use is in C:\MyApp\newicon.ico.
hIcon = ExtractIcon(App.hInstance, "C:\MyApp\newicon.ico", 0)
' Set this icon as the new class icon.
retval = SetClassLong(Form1.hWnd, GWL_HICON, hIcon)  ' set the class's icon, not the window's
' Note that here we can't destroy the icon we extracted because it
' is still in use by the class.

See Also

GetClassLong, SetWindowLong

Category

Window Classes

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: August 28, 1999
This page is copyright © 1999 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/s/setclasslong.html