WinAPI Wrapper
The WinAPI Wrapper library is a C++ class library that enhances the Win32 API with C++ functionality. It is not an equivalent of MFC. Although it can be used instead of MFC, it can also be used along with regular C Win32 API or with MFC in the same application.
The library contains miscellaneous classes that simplify writing Windows applications. Most of the classes’ functions are inline and do not impose any extra overhead; you could achieve the same code with the regular C Win32 API, but with the WinAPI Wrapper library it is just simplier.
The library currently has classes for windows, standard and common controls, GDI objects, device contexts, files, file mappings, file finding, image lists, registry keys, threads and synchronization objects, certain common dialogs, menus, sockets, etc.
The source code of the library is available on GitHub:
Example
Here is a simple example, a typical Hello World! application written using the WinAPI Wrapper.
// Include Wrapper's header #include // Make the WinAPI namespace local using namespace WinAPI; // Main window class class MainWindow: public Window { public: // Create the window MainWindow() { Create( "Example App" ); } // WM_DESTROY - quit application virtual void OnDestroy() { PostQuitMessage( 0 ); } // WM_PAINT - paint sample text virtual void OnPaint() { PaintDC dc( *this ); dc.TextOut( WPoint(50,50), "Hello, World!" ); } }; namespace { // The application object Application< MainWindow > app; }
why does the zip file contains an exe file? I thought it contained the sources…
The exe inside the zip is a Windows Installer that installs the sources as well as integrates help and project templates with Visual Studio (7 IIRC).
Why not just publish the source?
Yeah, I shall put it on github when I have some time. Thanks!
I just uploaded it on GitHub: https://github.com/cdragan/WinAPI-Wrapper
Hello, Chris.
My name is Daniel. I’ve been a hobbyist programmer since I was 6 years old or so (thanks to my father, who also tinkered with programming and my late mother who also used punch cards).
I’ve been working on my own Win32 API wrapper in C++ for 4 days now (5 week old son, and in between jobs makes it quite hard), and it appears from what you have: I was not far from the mark! I for some reason had a pure abstract virtual base embedded in my mind as ‘THE’ solution…!
I completely forgot about recursive functions (in (me) idiot speak: Returning a function call with a return instruction)! I feel so silly, but am incredibly thankful for you sharing your age-old project.
Thank you, very much!!
Hi Daniel. Please feel free to use my WinAPI wrapper and improve it as you see fit.
Thank you. 🙂
I appreciate that, and will definitely take you up on the offer. Haha.