Skip to content

Instantly share code, notes, and snippets.

@nvictor
Last active February 20, 2020 23:43
Show Gist options
  • Save nvictor/87e0632d3e8248181c7fe35d2f99b5b4 to your computer and use it in GitHub Desktop.
Save nvictor/87e0632d3e8248181c7fe35d2f99b5b4 to your computer and use it in GitHub Desktop.
Win32 API standard window proc
LRESULT __stdcall window_proc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
switch(message) {
// calls to BeginPaint and EndPaint are still needed
// even when using newer rendering engines
case WM_PAINT:
{
PAINTSTRUCT ps;
VERIFY(BeginPaint(window, &ps));
EndPaint(window, &ps);
}
break;
// indicates that application should terminate
// PostQuitMessage(0) posts a WM_QUIT message
// which GetMessage() handles
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(window, message, wparam, lparam);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment