Example of simple window with some code in external files.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include "AppFrame.h"
void OnDestroy(HWND hwnd) {
PostQuitMessage(0);
}
MESSAGEMAP_BEGIN(WndProc)
case WM_DESTROY: HANDLE_WM_DESTROY(hwnd, wParam, lParam, OnDestroy);
MESSAGEMAP_END
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hWnd = AppInitMainWindow(WndProc, lpszCmdLine, nCmdShow);
return AppMainLoop();
}
// AppFrame.h
#define MESSAGEMAP_BEGIN(fn) \
LRESULT CALLBACK fn(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){switch(uMsg){
#define MESSAGEMAP_END \
}return DefWindowProc(hwnd, uMsg, wParam, lParam);}
// in AppFrame.c
HWND AppInitMainWindow (void *WndProc, LPSTR lpszCmdLine, int nCmdShow);
int AppMainLoop(void);