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:

WinAPI Wrapper 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;
}
Advertisements
  1. Dr
    24.07.2012 at 16:25

    why does the zip file contains an exe file? I thought it contained the sources…

    • 5.08.2012 at 18:39

      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).

  2. Paul
    18.12.2014 at 00:41

    Why not just publish the source?

  3. Daniel Lawrence Banacka
    19.04.2016 at 02:42

    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!!

    • 19.04.2016 at 04:18

      Hi Daniel. Please feel free to use my WinAPI wrapper and improve it as you see fit.

      • Daniel Lawrence Banacka
        19.04.2016 at 17:28

        Thank you. 🙂

        I appreciate that, and will definitely take you up on the offer. Haha.

  1. No trackbacks yet.

Leave a Reply to Paul Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: