Created
November 28, 2012 13:48
-
-
Save tuttlem/4161428 to your computer and use it in GitHub Desktop.
DoubleBuffer - WndProc
This file contains hidden or 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
WndProc PROC hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD | |
; determine which message we need to process | |
cmp uMsg, WM_CREATE | |
je CreateMessage | |
cmp uMsg, WM_DESTROY | |
je DestroyMessage | |
cmp uMsg, WM_ERASEBKGND | |
je EraseBackgroundMessage | |
cmp uMsg, WM_CLOSE | |
je CloseMessage | |
cmp uMsg, WM_SIZE | |
je SizeMessage | |
cmp uMsg, WM_PAINT | |
je PaintMessage | |
jmp DefaultWindowHandler | |
CreateMessage: | |
; on creation, we want to create an initial back-buffer | |
invoke RecreateBackBuffer, hWin | |
jmp DefaultWindowHandler | |
DestroyMessage: | |
; on destruction, we just want to kill the back buffer | |
invoke DestroyBackBuffer, hWin | |
invoke PostQuitMessage, 0 | |
xor eax, eax | |
ret | |
EraseBackgroundMessage: | |
; we want to tell windows that we've handled the background | |
; being erased by ourselves so it doesn't try to and end up | |
; making our application flicker - poor form! | |
mov eax, 1 | |
ret | |
CloseMessage: | |
; closing the application just flips our message pump control | |
; variable so that we can break out | |
mov bRunning, 0 | |
jmp DefaultWindowHandler | |
SizeMessage: | |
; when the window changes size, we re-create the buffer | |
invoke RecreateBackBuffer, hWin | |
jmp DefaultWindowHandler | |
PaintMessage: | |
; painting is just flicking that back buffer onto the | |
; viewable video memory | |
invoke FlipBackBuffer, hWin | |
mov eax, 1 | |
ret | |
DefaultWindowHandler: | |
invoke DefWindowProc,hWin,uMsg,wParam,lParam | |
ret | |
WndProc ENDP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment