WinRegisterClass

Syntax
WinRegisterClass( hab, pszClassName, pfnWndProc, flStyle, cbWndData );

Usage Explanation
This API is normally used by the main window of all applications. Its main purpose is to register the address of the window procedure for this class. After this has been done, WinCreateWindow or WinCreateStdWindow can be used to create windows of this class, usually the main window of the app.

The private class name must not clash with the name of a public class in the same process. If this should happen, FALSE will be returned, and PMERR_PARAMETER_OUT_OF_RANGE will be returned from WinGetLastError. A private class can override an older private class, though, in which case the current parameters replace the old ones.

Private classes disappear when the owning process terminates, ie. when they are no longer needed.

Parameters

 * HAB hab (input): Anchor block handle.
 * PSZ pszClassName (input): The name of the class to register. This is usually specific to your application.
 * PFNWP pfnWndProc: The window procedure of the application.
 * ULONG flStyle: Default window style. This is the default style of any windows created of this class. This can be modified in the usual manner. If CS_PUBLIC is specified, any process can use this public class. Otherwise, a private class is created, available only to this process. You must only specify CS_PUBLIC for the shell process. This value is frequently 0L.


 * ULONG cbWindowData: The number of bytes reserved for storage for each window of this class which is created. If none is needed, specify 0L.

Returns

 * BOOL retval
 * TRUE means class was registered. FALSE means it was not. If FALSE is returned, you may use WinGetLastError to find out what went wrong. Possible errors are:

Include Info

 * 1) define INCL_WINWINDOWMGR
 * 2) include 

Gotchas
Only DLLs run by the shell at startup can use the CS_PUBLIC style.

Sample Code
MRESULT EXPENTRY WndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); HAB hab; HMQ hmq; CHAR szClassName[] = "My_class"; hab=WinInitialize(0L); hmq=WinCreateMsgQueue(hab, 0L); if (hmq) { retval = WinRegisterClass(hab,                             szClassName,                              (PFNWP) WndProc,                              0L,                              0L); .  .   . }
 * 1) define INCL_WINWINDOWMGR
 * 2) include 

Related Functions

 * WinInitialize
 * WinCreateMsgQueue
 * WinCreateStdWindow
 * WinCreateWindow