Skip to content

Instantly share code, notes, and snippets.

@mity
Created July 18, 2013 23:46
Show Gist options
  • Select an option

  • Save mity/6034044 to your computer and use it in GitHub Desktop.

Select an option

Save mity/6034044 to your computer and use it in GitHub Desktop.
Simple Windows app skeleton (CreateDialog())
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
/* To use this, you have to create rsource script to accompany this file,
* providing the dialog resource with this resource ID. */
#ifndef IDD_MAIN
#define IDD_MAIN 1000
#endif
static INT_PTR CALLBACK
dlg_proc(HWND dlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg) {
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return FALSE;
}
return TRUE;
}
int APIENTRY
_tWinMain(HINSTANCE instance, HINSTANCE prev_instance, TCHAR* cmd_line, int cmd_show)
{
HWND dlg;
MSG msg;
InitCommonControls();
dlg = CreateDialog(instance, MAKEINTRESOURCE(IDD_MAIN), NULL, dlg_proc);
if(!dlg)
return 1;
ShowWindow(dlg, cmd_show);
while(GetMessage(&msg, NULL, 0, 0)) {
if(IsDialogMessage(dlg, &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