Last active
February 20, 2020 23:43
-
-
Save nvictor/87e0632d3e8248181c7fe35d2f99b5b4 to your computer and use it in GitHub Desktop.
Win32 API standard window proc
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
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