Windows API Guide: PolyPolyline Function


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

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 4.0 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

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 for later use. Although this example doesn't actually use the newly created class, it shows how this class would be made and, later, destroyed. The code executes in the Load and Unload logic of a form window Form1.

' 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 Type WNDCLASSEX cbSize As Long style As Long lpfnWndProc As Long cbClsExtra As Long cbWndExtra As Long hInstance As Long hIcon As Long hCursor As Long hbrBackground As Long lpszMenuName As String lpszClassName As String hIconSm As Long End Type Public Const CS_OWNDC = &H20 Public Const CS_HREDRAW = &H2 Public Const CS_VREDRAW = &H1 Public Const COLOR_APPWORKSPACE = 12 Public Declare Function RegisterClassEx Lib "user32.dll" Alias "RegisterClassExA" _ (lpwcx As WNDCLASSEX) As Long Public Declare Function UnregisterClass Lib "user32.dll" Alias "UnregisterClassA" _ (ByVal lpClassName As Any, ByVal hInstance As Long) As Long Public Declare Function LoadCursorFromFile Lib "user32.dll" Alias "LoadCursorFromFileA" _ (ByVal lpFileName As String) As Long Public Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst _ As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long ' *** 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 ' The following function returns the value passed to it.  This allows the ' example to use the AddressOf operator to set a value in the structure. Public Function DummyFunc (ByVal dwValue As Long) As Long DummyFunc = dwValue End Function ' *** Place the following code inside window Form1. *** Private Sub Form_Load() Dim classinfo As WNDCLASSEX  ' holds info about the class Dim classatom As Long        ' receives an atom to the class just registered ' Load a decription of the new class into the strucure. With classinfo ' Of course, set the size of the structure. .cbSize = Len(classinfo) ' Class style: give each window its own DC; redraw when resized. .style = CS_OWNDC Or CS_HREDRAW Or CS_VREDRAW ' Use the window procedure above to process messages. .lpfnWndProc = DummyFunc(AddressOf WindowProc) ' We aren't using any extra information. .cbClsExtra = 0 .cbWndExtra = 0 ' Handle to the instance of this application. .hInstance = App.hInstance ' Use the icon stored in C:\MyApp\deficon.ico. .hIcon = ExtractIcon(App.hInstance, "C:\MyApp\deficon.ico", 0) ' Use the cursor stored in C:\MyApp\mouse.cur. .hCursor = LoadCursorFromFile("C:\MyApp\mouse.cur") ' Fill the background with the system color for an application's workspace. .hbrBackground = COLOR_APPWORKSPACE ' No menu resource to use. .lpszMenuName = "" ' Give the class a name. .lpszClassName = "CustomClass" ' Use the small icon stored in C:\MyApp\deficonsm.ico. .hIconSm = ExtractIcon(App.hInstance, "C:\MyApp\deficonsm.ico", 0) End With ' Finally, register the class. classatom = RegisterClassEx(classinfo) ' Now the class CustomClass can be used to create windows. End Sub Private Sub Form_Unload(Cancel As Integer) Dim retval As Long  ' return value ' Unregister the window class when the form closes. retval = UnregisterClass("CustomClass", App.hInstance) End Sub

See Also

RegisterClass, UnregisterClass

Category

Window Classes

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


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



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net