At one time I found it necessary to delve into the guts of the Windows API in order to overcome some obstacles I was having.  I will not go into why I had to do what I did, or why I could not have gotten away with MFC or another framework.  I will show the results of my efforts, and maybe the lessons learned will be useful to somebody else in the future.

What I ended up doing was creating a Window's API wrapper that was fairly easy to use, and exposed the 'guts' of Windows in a fairly intuitive manner.  You may see some other wrappers at Relisoft and GameDev (GameDev shows Oluseyi Sonaiya's approach).  Those two wrappers are equivalent to the first version of my wrapper in that they only show the basics of 'objectivizing' a window procedure.  They don't show how to further 'objectivize' window controls, such as edit boxes and buttons (even though Relisoft states that theirs does).  Window's controls 'objectivization' can be handled using the API, but that is a tedious affair.  The second version of the wrapper overcomes much of that tedium.

(Just lately I came across a templated Win GUI framework.  I am not overly fond of it, as I don't particularly like the syntax, but it appears to be very powerful, so I am mentioning it in case you find it useful.  In my opinion, DWinLib is just as powerful, and the syntax is much simpler.  The authors of the Win GUI library tout the fact that you can use the STL within it, but it is apparent that you don't need to go such a route just to use the STL in a Windows program.)

Oh yeah, I should mention perhaps the greatest wrapper of them all - Borland's Visual Class Library.  The VCL influenced my design in the fact that I was aiming at making DWinLib almost as easy to use as the VCL.  The internals of the VCL didn't influence me that much, as I found it frustrating to follow through everything it was doing, but if you want to understand that wrapper, I've came across Damon Chandler's explanation (see the CAQ Fundamentals section), and you may find that of some use and interest.

The first version of the wrapper is about the simplest approach I can see.  It does not even use a map for determining the appropriate window class to call, so it should be even faster than Oluseyi's method, if you are concerned for speed.  (With the operating characteristics of todays processors, that seems like needless worry.)  Here is the bare-bones version, with a cool little sample application, if I say so myself.

Once you have mastered that, here is a more 'grown-up' version of the wrapper.  It has additions that make wrapping windows controls much easier.  (And no, Relisoft's approach had no influence upon this method - they are totally different.)  It took much more effort to refine the second version, and I am very proud of it.

I hope that this information has been useful to you, and that even if you don't use it, your understanding of the Windows API has been considerably enriched.

David

All content © 2005-2010, David O'Neil