[ Home | Alpha index | Topic index | Tutorials | Download | Feedback ]

The OS/2 API Project


[ Syntax | Params | Returns | Include | Usage | Structs | Gotchas | Code | Also ]


retval = WinRegisterClass( hab, pszClassName, pfnWndProc, flStyle, cbWndData );


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.

CS_CLIPCHILDREN Clip window drawing to children's boundaries
CS_CLIPSIBLINGS Clip window drawing to siblings' boundaries
CS_FRAME Frame window
CS_HITTEST When pointer is in window, WM_HITTEST is sent
CS_MOVENOTIFY WM_MOVE messages will be sent to window
CS_PARENTCLIP Clip window drawing to parent's boundaries
CS_PUBLIC Makes the new class public (see above)
CS_SAVEBITS Save area covered by window for faster redraws
CS_SIZEREDRAW Invalidates whole window when it is resized
CS_SYNCPAINT Window is repainted synchronously (WM_PAINT is SENT)
... Other Control Styles

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


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:
0x1003 PMERR_PARAMETER_OUT_OF_RANGE A parameter was out of range (?).
0x1013 PMERR_INVALID_HATOMTBL An invalid atom table handle was passed.
0x1015 PMERR_INVALID_ATOM_NAME An invalid atom name string was given.
0x1016 PMERR_INVALID_INTEGER_ATOM The atom specified is not a valid integer atom.
0x1017 PMERR_ATOM_NAME_NOT_FOUND The atom name given was not in the atom table.
0x1019 PMERR_INVALID_FLAG An invalid bit was set for a parameter.
0x1208 PMERR_INVALID_PARAMETERS One or more parameters were invalid.

Include Info

#include <os2.h>

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.

Relevant Structures


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

Sample Code

#define INCL_WINWINDOWMGR #include <os2.h> 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); . . . }

See Also

WinInitialize, WinCreateMsgQueue, WinCreateStdWindow, WinCreateWindow


Carsten Whimster - bcrwhims@uwaterloo.ca


Last modified May 23/1996
Please send all errors, comments, and suggestions to: timur@vnet.ibm.com

The OS/2 API Project