It is my experience that few C++ newcommers realize that the Win32 Api is already extremely object oriented. Perhaps the reason for this is that the Api was created before C++ came into widespread use. At the time the Api was taking shape, that is, in the mid 80s, the ideas central to OOP existed, and in terms of the Win Api they were implemented in C - not C++.
I think this idea is alien to modern C++ coders, that is, the idea that OOP can be done in C. Nonwithstanding this, it can be. The Windows Api is proof of it.
You have to first realize that the WM_CREATE message a parent Window receives at the time of a CreateWindow() call is essentially a call of the Window's constructor. My own style of programming is to create all child window controls within the constructor of the parent window, and so I do them in a message handler for the WM_CREATE message, i.e.,...
1 2 3 4 5
|
long fnWndProc_OnCreate(....)
{
...
...
}
| |
I have seen other styles where child window controls are created in the same procedure as CreateWindow() calls on the parent, and naturally, the CreateWindow() call returns a HWND to allow for this. However, stylelistically, I prefer creating child windows of a parent as part of and within a constructor of the parent, because I'm a believer in OOP principles.
However, because I also am a believer in efficiency, performance, and small program size with a minimum of application dependencies, I do not create C++ wrappers around the Win32 Api as you are doing. I prefer dealing with it on its own terms in terms of its inherent C based OOP design.
In that design one attaches objects to the Window Class, i.e., child window controls and memory allocations for memory required by instances of the class, either through .cbWndExtra bytes allocated at class registration time, or through Window Properties accessable by GetProp() / SetProp() Apis.
In this programming technique there is ABSOLUTELY, ABSOLUTELY no room for the existance of globally allocated data, because, under the principles of OOP design, all data must be associated with an object, and should not be accessable from objects not having a right to that data.
Don't know if I'm answering your question, but I'm trying.