Listing 2 The equivalent of Listing 1 using wrapper functions in C

#include "windows.h"

typedef int        BOOL;
typedef WNDCLASS   MYWCLASS;
typedef WNDPROC    MYWNDPROC;
typedef HINSTANCE  MYHINSTANCE;
typedef HCURSOR    MYHCURSOR;
typedef HBRUSH     MYHBRUSH;

void WCL_Init (MYWCLASS *wndclass, char *szAppName,
       MYWNDPROC WndProc, MYHINSTANCE hInstance,
       char *szMenuName)
{
   wndclass->style = CS_HREDRAW | CS_VREDRAW;
   wndclass->lpfnWndProc = WndProc;
   wndclass->cbClsExtra = 0;
   wndclass->cbWndExtra = 0;
   wndclass->hInstance = hInstance;
   wndclass->hIcon = LoadIcon (NULL,
                            IDI_APPLICATION);
   wndclass->hCursor = LoadCursor (NULL, IDC_ARROW);
   wndclass->hbrBackground = GetStockObject (WHITE_BRUSH);
   wndclass->lpszMenuName = szMenuName;
   wndclass->lpszClassName = szAppName;
}

void WCL_SetCursor (MYWCLASS *wndclass,
       MYHCURSOR hCursor)
{
   wndclass->hCursor = hCursor;
}

void WCL_SetBackground (MYWCLASS *wndclass,
       MYHBRUSH hbrBackground)
{
wndclass->hbrBackground = hbrBackground;
}

void WCL_SetMenu (MYWCLASS *wndclass,
                char *szMenuName)
{
   wndclass->lpszMenuName = szMenuName;
}

BOOL WCL_RegisterClass (MYWCLASS *wndclass)
{
   return (RegisterClass (wndclass));
}

/* End of File */