Created
July 18, 2013 23:45
-
-
Save mity/6034036 to your computer and use it in GitHub Desktop.
Simple Windows app skeleton (CreateWindow())
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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