RegisterClassEx Function

Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" (lpwcx As WNDCLASSEX) As Long

Platforms

Description & Usage

RegisterClassEx registers a new window class for use. Only after registering the window class can it be used to create windows. After the window class is completely finished being used, use UnregisterClass to unregister it.

Return Value

If an error occured, the function returns 0. If successful, the function returns an atom identifying the class.

Visual Basic-Specific Issues

None.

Parameters

lpwcx
Information about the window class being registered.

Example

' Register a new window class.  The various properties to
' give it will be explained in the code.

' *** Place the following code in a module. ***
' Define the window procedure to use for the class.  Here, we'll
' just make a wrapper for the default window procedure.
Public Function WindowProc (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  ' Return whatever the default window procedure returns.
  WindowProc = DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function

' *** Place the following code where you want to register the class. ***
Dim classinfo As WNDCLASSEX ' holds info about the class
Dim classatom As Long  ' receives an atom to the class just registered

' Set the various data members of the structure.
' Of course, set the size of the structure.
classinfo.cbSize = Len(classinfo)
' Class style: give each window its own DC; redraw when resized.
classinfo.style = CS_OWNDC Or CS_HREDRAW Or CS_VREDRAW
' Use the window procedure above to process messages.
classinfo.lpfnWndProc = AddressOf WindowProc
' We aren't using any extra information.
classinfo.cbClsExtra = 0
classinfo.cbWndExtra = 0
' Handle to the instance of this application.
classinfo.hInstance = App.hInstance
' Use the icon stored in C:\MyApp\deficon.ico.
classinfo.hIcon = ExtractIcon(App.hInstance, "C:\MyApp\deficon.ico", 0)
' Use the cursor stored in C:\MyApp\mouse.cur.
classinfo.hCursor = LoadCursorFromFile("C:\MyApp\mouse.cur")
' Fill the background with the system color for an application's workspace.
classinfo.hbrBackground = COLOR_APPWORKSPACE
' No menu resource to use.
classinfo.lpszMenuName = ""
' Give the class a name.
classinfo.lpszClassName = "CustomClass"
' Use the small icon stored in C:\MyApp\deficonsm.ico.
classinfo.hIconSm = ExtractIcon(App.hInstance, "C:\MyApp\deficonsm.ico", 0)

' Finally, register the class.
classatom = RegisterClassEx(classinfo)
' Now the class CustomClass can be used to create windows.

' *** Place the following code where you wish to unregister the window class. ***
Dim retval As Long

' Unregister the window class.
retval = UnregisterClass("CustomClass", App.hInstance)

Related Functions

RegisterClass, UnregisterClass

Category

Window Classes

Back to the index.


Last Modified: August 24, 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/r/registerclassex.html