Ember

handler

Dec 26th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1.     // Default message handler ------------------------------------------------------------
  2.     LRESULT CALLBACK Engine::WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
  3.     {
  4.         switch(umessage)
  5.         {
  6.             // Check if the window is being destroyed
  7.             case WM_DESTROY:
  8.             {
  9.                 PostQuitMessage(0);
  10.                 return 0;
  11.             }
  12.  
  13.             // Check if the window is being closed
  14.             case WM_CLOSE:
  15.             {
  16.                 PostQuitMessage(0);
  17.                 return 0;
  18.             }
  19.  
  20.             // Check if a key has been pressed on the keyboard
  21.             case WM_KEYDOWN:
  22.             {
  23.                 // If a key is pressed send it to the input object so it can record that state
  24.                 mInput->KeyDown((unsigned int)wparam);
  25.                 return 0;
  26.             }
  27.  
  28.             // Check if a key has been released on the keyboard
  29.             case WM_KEYUP:
  30.             {
  31.                 // If a key is released then send it to the input object so it can unset the state for that key
  32.                 mInput->KeyUp((unsigned int)wparam);
  33.                 return 0;
  34.             }
  35.  
  36.             // All other messages pass to the message handler in the system class
  37.             default:
  38.             {
  39.                 return DefWindowProc(hwnd, umessage, wparam, lparam);
  40.             }
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment