Main


Description:
This is the main.h and main.cpp file that gets used for most of my projects. It can either use straight win32api, or include some of the MFC (not the windowing portions, but portions like CString, and the database classes that are extremly usefull).
 
Code:
// -------------------- Header

#pragma once

#include <windows.h>

/* // MFC Support
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>

#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif

#include "resource.h"
*/

/* // Winsock 2 Support
#include <winsock2.h>
#include <mswsock.h>
#include <afxsock.h>
*/

/* // MFC Template support (CList)
#include <afxtempl.h>
#include <afxdb.h>
*/

// -------------------- Code

#include "main.h"
#include "MainWnd.h"

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, 
            PSTR szCmdLine, int iCmdShow) {

    CMainWnd    mwMain;
    MSG         msg;
    HWND        hWnd;
    int         iReturn = 0;

    if ( (!mwMain.PrevInst()) ) {

        hWnd = mwMain.Create(hInstance);

        while (GetMessage (&msg, NULL, 0, 0)) {
            TranslateMessage (&msg);
            DispatchMessage (&msg);
        }

        iReturn = msg.wParam;
    }

    return iReturn;
}


/* Accelerator table code:
//  HACCEL              hAccel;
//      hAccel = LoadAccelerators (hInstance, 
//               MAKEINTRESOURCE(IDR_ACCELERATOR));
//          if (!TranslateAccelerator(hWnd, hAccel, &msg))
//          { / * Translate/Dispatch * /
//          }
*/
 
Sample Usage:
 
n/a