Windows API Guide: PolyPolygon Function


Declare Function RegisterClass Lib "user32.dll" Alias "RegisterClassA" (lpWndClass As WNDCLASS) As Long

Platforms

  • Windows 95: Supported but Obsolete; use RegisterClassEx instead.
  • Windows 98: Supported but Obsolete; use RegisterClassEx instead.
  • Windows NT: Requires Windows NT 3.1 or later but Obsolete in Windows NT 4.0 or later; use RegisterClassEx instead.
  • Windows 2000: Supported but Obsolete; use RegisterClassEx instead.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

RegisterClass registers a new window class for use. Only after registering the window class can it be used to create windows. This function is unable to set the small icon associated with a window class; to do that, use the more powerful RegisterClassEx function. After the window class is completely finished being used, use UnregisterClass to unregister it.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns an atom identifying the class.

Visual Basic-Specific Issues

None.

Parameters

lpWndClass
Information about the window class being registered.

Example

' This code is licensed according to the terms and conditions listed here. ' 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 WNDCLASS ' 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. ' 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" ' Finally, register the class. classatom = RegisterClass(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)

See Also

RegisterClassEx, UnregisterClass

Category

Window Classes

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


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