Share via


TN070: MFC Window Class Names

Note

The following technical note has not been updated since it was first included in the online documentation. As a result, some procedures and topics might be out of date or incorrect. For the latest information, it is recommended that you search for the topic of interest in the online documentation index.

MFC windows use a dynamically created class name that reflects the features of the window. MFC generates class names dynamically for frame windows, views, and popup windows produced by the application. Dialog boxes and controls produced by an MFC application have the Windows-supplied name for the class of window in question.

You can replace the dynamically provided class name by registering your own window class and using it in an override of PreCreateWindow. Their MFC-supplied class names fit one of the two following forms:

Afx:%x:%x
Afx:%x:%x:%x:%x:%x

The hex digits that replace the %x characters are filled in from data from the WNDCLASS structure. MFC uses this technique so that multiple C++ classes requiring identical WNDCLASS structures can share the same registered window class. Unlike most simple Win32 applications, MFC applications have only one WNDPROC, so you can easily share WNDCLASS structures to save time and memory. The replaceable values for the %x characters shown above are as follows:

  • WNDCLASS.hInstance

  • WNDCLASS.style

  • WNDCLASS.hCursor

  • WNDCLASS.hbrBackground

  • WNDCLASS.hIcon

The first form (Afx:%x:%x) is used when hCursor, hbrBackground, and hIcon are all NULL.

See Also

Reference

TN020: ID Naming and Numbering Conventions

Other Resources

Technical Notes by Number

Technical Notes by Category