Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Global variables -------------------------------------------------------------------
- static Engine* ApplicationHandle = 0;
- // Default message handler ------------------------------------------------------------
- static LRESULT CALLBACK WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
- {
- switch(umessage)
- {
- // Check if the window is being destroyed
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- // Check if the window is being closed
- case WM_CLOSE:
- {
- PostQuitMessage(0);
- return 0;
- }
- // All other messages pass to the message handler in the system class
- default:
- {
- return ApplicationHandle->MessageHandler(hwnd, umessage, wparam, lparam);
- }
- }
- }
- // Application message handler --------------------------------------------------------
- LRESULT CALLBACK MessageHandler(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
- {
- switch(umessage)
- {
- // Check if a key has been pressed on the keyboard
- case WM_KEYDOWN:
- {
- // If a key is pressed send it to the input object so it can record that state
- mInput->KeyDown((unsigned int)wparam);
- return 0;
- }
- // Check if a key has been released on the keyboard
- case WM_KEYUP:
- {
- // If a key is released then send it to the input object so it can unset the state for that key
- mInput->KeyUp((unsigned int)wparam);
- return 0;
- }
- // All other messages pass to the default message handler
- default:
- {
- return DefWindowProc(hwnd, umessage, wparam, lparam);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment