What's the purpose of registering a window class via WNDCLASSEX
and RegisterClassEx()
when creating a window in a Windows API application?
The separation of window attributes into CreateWindow() stuff and RegisterClass() stuff was done early on to enable the creation of uniformly-behaving windows. Dialog controls (buttons, listboxes, etc.) are a prime example - they all share a class. That means - they share a window procedure, that means - they share painting logic, input reactions, custom messages, notifications, etc.
On the app level, the most typical case when you have many windows of the same class is documents within a multiple-document interface. Sometimes people introduce app-specific controls. So the distinction serves its purpose.
Main purpose is giving the system the right WndProc
to call when there is something in the message queue to process.
There are some flags, but main point is the above.
Window classes correspond to types of 'widgets' on the UI:
WndProc
is the sole driver of the behavior of the widget.
Hence the mapping: widget (control type) -> wndclass
-> WndProc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With