DOC: AfxRegisterWndClass with WS_* Styles Causes Exception (132291)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++ for Windows, 16-bit edition 1.0
    • Microsoft Visual C++ for Windows, 16-bit edition 1.5
    • Microsoft Visual C++ for Windows, 16-bit edition 1.51
    • Microsoft Visual C++ for Windows, 16-bit edition 1.52
    • Microsoft Visual C++, 32-bit Editions 4.0
    • Microsoft Visual C++, 32-bit Editions 4.0a
    • Microsoft Visual C++, 32-bit Editions 4.1
    • Microsoft Visual C++, 32-bit Editions 4.2
    • Microsoft Visual C++, 32-bit Editions 4.2b
    • Microsoft Visual C++, 32-bit Editions 5.0
    • Microsoft Visual C++, 32-bit Editions 6.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2
    • Microsoft Visual C++, 32-bit Professional Edition 4.2
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2b
    • Microsoft Visual C++, 32-bit Professional Edition 4.2b
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q132291

SUMMARY

The documentation for AfxRegisterWndClass states that the nClassStyle parameter can be a combination of any window style or control style.

If a window style (for example, WS_VISIBLE and WS_CHILD) is used in this parameter, then the AfxRegisterWndClass function call causes a resource exception to be thrown. Your application will probably fail, and give a message similar to this:
   Unhandled Exception in myapp.exe (MFC30D.DLL): 0xE06D7363: Microsoft
      C++ Exception.
					

MORE INFORMATION

Only Window CLASS styles (not window styles) can be used in the nClassStyle parameter. These class styles are listed in the documentation for the WNDCLASS structure. Examples of window class styles include:
   CS_HREDRAW
   CS_VREDRAW
   CS_DBLCLKS
				
NOTE: This problem was fixed in Microsoft Visual C++ versions 4.0 and later.

Modification Type:MajorLast Reviewed:12/9/2003
Keywords:kbBug kbdocerr kbdocfix KbUIDesign kbVC400fix KB132291