PRB: RegisterClass()/ClassEx() Fails If cbWndExtra > 40 BytesLast reviewed: September 29, 1995Article ID: Q131288 |
The information in this article applies to:
SYMPTOMSUnder Windows 95, a call to RegisterClass() or RegisterClassEx() returns NULL if a value greater than 40 is specified for the cbWndExtra or cbClsExtra members of the WNDCLASS or WNDCLASSEX structure.
CAUSEWindows 95 checks to see if cbWndExtra or cbClsExtra is greater than 40. If so, it outputs these debug messages and returns NULL to indicate failure:
RegisterClassEx: Unusually large cbClsExtra (>40) RegisterClassEx: Unusually large cbWndExtra (>40) RESOLUTIONIf more than 40 bytes are needed to store window-specific or class-specific information, an application should allocate memory. Then set the cbWndExtra or cbClsExtra to 4 bytes, and pass the pointer to the allocated memory by using SetClassLong() as follows:
SetClassLong (hWnd, GCL_CBCLSEXTRA, lpMemoryAllocated); SetClassLong (hWnd, GCL_CBWNDEXTRA, lpMemoryAllocated);The pointer can then be retrieved when needed by using GetClassLong() as follows:
lpMemoryAllocated = GetClassLong (hWnd, GCL_CBCLSEXTRA); lpMemoryAllocated = GetClassLong (hWnd, GCL_CBWNDEXTRA); STATUSThis behavior is by design. However, as of version 3.51, Windows NT does not have this 40-byte limitation.
|
Additional reference words: 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |