Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Registering Window Class

Tags:

winapi

I guess my question is relatively easy for those of you who spent time dealing with Win32 API.

So my question is:
After initializing a WNDCLASSEX instance we need to "register" it using the "RegisterClassEx" function, why? Why do we do that? What's the meaning of this registration and in what cases I need to register things?

like image 271
RiskX Avatar asked May 14 '26 09:05

RiskX


1 Answers

The ATOM returned by RegisterClassEx uniquely identifies your "window class" which can then be referred to in other windows APIs. [MSDN]

Effectively it is a hash so as to reduce the amount of data processed each time a window is created or looked for. It does also mean that multiple windows with same features can be easily created and identified.

I was addressing the practical reasons above. Hans Passant's answer correctly explains this is the OO class concept provided for C. Further MSDN example.

like image 99
Mark Hurd Avatar answered May 16 '26 20:05

Mark Hurd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!