void MainMouseRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { // Send it to HandleKeys first in case user set a keybind to one // of the mouse buttons. HandleKeys(0); /* See if a module wants to handle mouse click */ if (ModuleEvent(EVENT_MOUSECLICK, hwnd, fDoubleClick, x, y, keyFlags) == False) return; switch (state) { case STATE_GAME: GameMouseButtonDown(hwnd, fDoubleClick, x, y, keyFlags); break; } }
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // this is the main message handler of the system PAINTSTRUCT ps; // used in WM_PAINT HDC hdc; // handle to a device context // what is the message switch(msg) { case WM_LBUTTONDOWN: case WM_LBUTTONUP: { NimblePoint p; p.x = (int)LOWORD(lparam); p.y = (int)HIWORD(lparam); if( msg==WM_LBUTTONDOWN ) GameMouseButtonDown( p, 0 ); else GameMouseButtonUp( p, 0 ); break; } case WM_MOUSELEAVE: RequestedTrackMouseEvent = false; HostShowCursor(true); break; case WM_MOUSEMOVE: { if (!RequestedTrackMouseEvent) { // First time mouse entered my window: // Request leave notification TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.hwndTrack = hwnd; tme.dwFlags = TME_LEAVE; TrackMouseEvent(&tme); RequestedTrackMouseEvent = true; } NimblePoint p; p.x = (int)LOWORD(lparam); p.y = (int)HIWORD(lparam); GameMouseMove( p ); break; } case WM_CREATE: // Do initialization stuff here return 0; case WM_PAINT: // Start painting hdc = BeginPaint(hwnd,&ps); // End painting EndPaint(hwnd,&ps); return 0; case WM_MOVE: return 0; case WM_SIZE: // Extract new window size // Round to multiple of four, because some of our loop unrollings depend upon such. WindowWidth = RoundAndClip(LOWORD(lparam)); WindowHeight = HIWORD(lparam); ResizeOrMove = true; return 0; case WM_COMMAND: break; case WM_DESTROY: // Kill the application PostQuitMessage(0); return 0; case WM_CHAR: { if( GameKeyDown(wparam) ) PostMessage(hwnd, WM_DESTROY,0,0); return 0; } default: break; } // end switch // Process any messages that we didn't take care of return (DefWindowProc(hwnd, msg, wparam, lparam)); } // end WinProc