Concept of WNDCLASSEX, good programming habits and WndProc for system classes

Posted by luiscubal on Stack Overflow See other posts from Stack Overflow or by luiscubal
Published on 2009-03-11T18:48:15Z Indexed on 2010/06/18 9:33 UTC
Read the original article Hit count: 256

Filed under:
|
|
|

I understand that the Windows API uses "classes", relying to the WNDCLASS/WNDCLASSEX structures.

I have successfully gone through windows API Hello World applications and understand that this class is used by our own windows, but also by Windows core controls, such as "EDIT", "BUTTON", etc. I also understand that it is somehow related to WndProc(it allows me to define a function for it)

Although I can find documentation about this class, I can't find anything explaining the concept.

So far, the only thing I found about it was this:

A Window Class has NOTHING to do with C++ classes.

Which really doesn't help(it tells me what it isn't but doesn't tellme what it is). In fact, this only confuses me more, since I'd be tempted to associate WNDCLASSEX to C++ classes and think that "WNDCLASSEX" represents a control type . So, my first question is What is it?

In second place, I understand that one can define a WndProc in a class. However, a window can also get messages from the child controls(or windows, or whatever they are called in the Windows API). How can this be?

Finally, when is it a good programming practise to define a new class? Per application(for the main frame), per frame, one per control I define(if I create my own progress bar class, for example)?

I know Java/Swing, C#/Windows.Form, C/GTK+ and C++/wxWidgets, so I'll probably understand comparisons with these toolkits.

© Stack Overflow or respective owner

Related posts about c

    Related posts about best-practices