Skip to content

Instantly share code, notes, and snippets.

@mity
Created July 18, 2013 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mity/6034036 to your computer and use it in GitHub Desktop.
Save mity/6034036 to your computer and use it in GitHub Desktop.
Simple Windows app skeleton (CreateWindow())
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
static LRESULT CALLBACK
win_proc(HWND win, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg) {
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(win, msg, wp, lp);
}
int APIENTRY
_tWinMain(HINSTANCE instance, HINSTANCE prev_instance, TCHAR* cmd_line, int cmd_show)
{
WNDCLASS wc = { 0 };
HWND win;
MSG msg;
InitCommonControls();
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = win_proc;
wc.hInstance = instance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = _T("window_class");
RegisterClass(&wc);
win = CreateWindow(_T("window_class"), _T("Window Title"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, instance, NULL);
ShowWindow(win, cmd_show);
while(GetMessage(&msg, NULL, 0, 0)) {
if(IsDialogMessage(win, &msg))
continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment