// WindowProc --- Handles messages for the main application window |
static long FAR PASCAL WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) |
{ |
PAINTSTRUCT ps; |
HDC hdc; |
static BOOL fFirstPaint = TRUE; |
switch( message ) |
{ |
case WM_KEYDOWN: //Check for key presses |
switch( wParam ) |
{ |
case VK_UP: |
UpdateFrame("UP"); |
break; |
case VK_DOWN: |
UpdateFrame("DOWN"); |
break; |
case VK_LEFT: |
UpdateFrame("LEFT"); |
break; |
case VK_RIGHT: |
UpdateFrame("RIGHT"); |
break; |
case VK_ESCAPE: |
case VK_F12: |
PostMessage(hWnd, WM_CLOSE, 0, 0); |
return 0; |
} |
break; |
case WM_PAINT: |
hdc = BeginPaint( hWnd, &ps ); |
EndPaint( hWnd, &ps ); |
return 1; |
case WM_DESTROY: |
// We're done, clean up |
CleanUp(); |
break; |
} |
return DefWindowProc(hWnd, message, wParam, lParam); |
} |
The message processing function - WindowProc() |