What is the purpose of registering window classes?

What is the purpose of registering a window class with WNDCLASSEX and RegisterClassEx() when creating a window in a Windows API application?

+7
source share
2 answers

The separation of window attributes into CreateWindow () and RegisterClass () was done at an early stage to ensure that windows were created with uniform maintenance. Dialog controls (buttons, lists, etc.) are a prime example - they all share a class. This means that they share the window procedure, it means that they share the drawing logic, input reactions, user messages, notifications, etc.

At the application level, the most typical case when you have many windows of the same class are documents in the interface with several documents. Sometimes people implement application-specific controls. Thus, the difference serves its purpose.

+5
source

The main goal is to give the system the correct WndProc to call when there is something in the message queue.

There are several flags, but the main thing is higher.

Window classes correspond to the types of "widgets" in the user interface:

  • Button
  • check box
  • scroll bars
  • dropdown
  • Listbox

WndProc is the only driver for widget behavior.

Therefore, the mapping: widget (control type) β†’ wndclass β†’ WndProc

+5
source

All Articles