1 | // WindowProc --- Handles messages for the main application window |
2 | static long FAR PASCAL WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) |
3 | { |
4 | PAINTSTRUCT ps; |
5 | HDC hdc; |
6 | static BOOL fFirstPaint = TRUE; |
7 | switch( message ) |
8 | { |
9 | case WM_KEYDOWN: //Check for key presses |
10 | switch( wParam ) |
11 | { |
12 | case VK_UP: |
13 | UpdateFrame("UP"); |
14 | break; |
15 | case VK_DOWN: |
16 | UpdateFrame("DOWN"); |
17 | break; |
18 | case VK_LEFT: |
19 | UpdateFrame("LEFT"); |
20 | break; |
21 | case VK_RIGHT: |
22 | UpdateFrame("RIGHT"); |
23 | break; |
24 | case VK_ESCAPE: |
25 | case VK_F12: |
26 | PostMessage(hWnd, WM_CLOSE, 0, 0); |
27 | return 0; |
28 | } |
29 | break; |
30 | case WM_PAINT: |
31 | hdc = BeginPaint( hWnd, &ps ); |
32 | EndPaint( hWnd, &ps ); |
33 | return 1; |
34 | case WM_DESTROY: |
35 | // We're done, clean up |
36 | CleanUp(); |
37 | break; |
38 | } |
39 | return DefWindowProc(hWnd, message, wParam, lParam); |
40 | } |
41 | The message processing function - WindowProc() |