bool iWidget::ProcessMessage(eGuiMessage aMessage, cGuiMessageData &aData) { if(IsEnabled()==false) return false; aData.mMessage = aMessage; bool bRet = false; bRet = OnMessage(aMessage,aData); //This can override any message. ///////////////////////////////////////// //Call the correct virtual function if(bRet==false) { switch(aMessage) { case eGuiMessage_MouseMove: bRet = OnMouseMove(aData); break; case eGuiMessage_MouseDown: bRet = OnMouseDown(aData); break; case eGuiMessage_MouseUp: bRet = OnMouseUp(aData); break; case eGuiMessage_MouseDoubleClick: bRet = OnMouseDoubleClick(aData); break; case eGuiMessage_MouseEnter: bRet = OnMouseEnter(aData); break; case eGuiMessage_MouseLeave: bRet = OnMouseLeave(aData); break; case eGuiMessage_KeyPress: bRet = OnKeyPress(aData); break; case eGuiMessage_GotFocus: bRet = OnGotFocus(aData); break; case eGuiMessage_LostFocus: bRet = OnLostFocus(aData); break; } } ///////////////////////////////////////// //Process user callbacks for the event. if(ProcessCallbacks(aMessage,aData)) bRet = true; return bRet; }
bool iWidget::ProcessMessage(eGuiMessage a_Message, cGuiMessageData &a_Data) { if (IsEnabled()==false) return false; a_Data.m_Message = a_Message; bool bRet = false; bRet = OnMessage(a_Message, a_Data); if (bRet==false) { switch(a_Message) { case eGuiMessage_MouseMove: bRet = OnMouseMove(a_Data);break; case eGuiMessage_MouseDown: bRet = OnMouseDown(a_Data);break; case eGuiMessage_MouseUp: bRet = OnMouseUp(a_Data);break; case eGuiMessage_MouseDoubleClick: bRet = OnMouseDoubleClick(a_Data);break; case eGuiMessage_MouseEnter: bRet = OnMouseEnter(a_Data);break; case eGuiMessage_MouseLeave: bRet = OnMouseLeave(a_Data);break; case eGuiMessage_GotFocus: bRet = OnGotFocus(a_Data);break; case eGuiMessage_LostFocus: bRet = OnLostFocus(a_Data);break; case eGuiMessage_KeyPress: bRet = OnKeyPress(a_Data);break; } } if (ProcessCallbacks(a_Message, a_Data)) bRet = true; return bRet; }
INT_PTR GenericWindow::HandleDialogMessage (UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_MOUSEMOVE: if (!m_flagMouseTracking) { // register for mouse out message (TME_LEAVE) TRACKMOUSEEVENT trackMouseEvent; trackMouseEvent.cbSize = sizeof (trackMouseEvent); trackMouseEvent.dwFlags = TME_LEAVE; trackMouseEvent.dwHoverTime = 0; trackMouseEvent.hwndTrack = GetHandle (); m_flagMouseTracking = ::TrackMouseEvent (&trackMouseEvent); } OnMouseMove (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_MOUSELEAVE: OnMouseLeave (); m_flagMouseTracking = FALSE; break; case WM_LBUTTONDOWN: OnMouseDown (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONUP: OnMouseUp (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONDOWN: OnMouseDown (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONUP: OnMouseUp (0, 0, LOWORD(lParam), HIWORD(lParam)); OnContextMenu ( ); break; case WM_CHAR: OnKeyPress ( (int)wParam, LOWORD(lParam) ); break; case WM_KEYDOWN: OnKeyDown ( (int)wParam ); break; case WM_NCDESTROY: OnPreDestroy (); m_hWnd = NULL; break; case WM_DESTROY: OnDestroy (); break; case WM_SIZE: { int cx, cy; cx = LOWORD(lParam); cy = HIWORD(lParam); OnResize (cx, cy); } break; case WM_SETFOCUS: OnGotFocus (); break; case WM_KILLFOCUS: OnLostFocus (); break; case WM_COMMAND: OnCommand ( LOWORD(wParam) ); break; case WM_CONTEXTMENU: OnContextMenu ( ); break; default: return FALSE; } return TRUE; }
LRESULT GenericWindow::HandleMessage (UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_MOUSEMOVE: if (!m_flagMouseTracking) { // register for mouse out message (TME_LEAVE) TRACKMOUSEEVENT trackMouseEvent; trackMouseEvent.cbSize = sizeof (trackMouseEvent); trackMouseEvent.dwFlags = TME_LEAVE; trackMouseEvent.dwHoverTime = 0; trackMouseEvent.hwndTrack = GetHandle (); m_flagMouseTracking = ::TrackMouseEvent (&trackMouseEvent); } OnMouseMove (0, -1, LOWORD(lParam), HIWORD(lParam)); break; case WM_MOUSELEAVE: OnMouseLeave (); m_flagMouseTracking = FALSE; break; case WM_LBUTTONDOWN: OnMouseDown (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONUP: OnMouseUp (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONDOWN: OnMouseDown (0, 1, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONUP: OnMouseUp (0, 1, LOWORD(lParam), HIWORD(lParam)); OnContextMenu ( ); break; case WM_ERASEBKGND: // we'll erase the background during the WM_PAINT message as necessary // to support dynamic background color for views // return FALSE to indicate we didn't erase the background here. return FALSE; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = ::BeginPaint (m_hWnd, &ps); // erase the background if required if (ps.fErase) { OnEraseBackground (hdc, ps); ps.fErase = FALSE; } OnPaint (hdc, ps); ::EndPaint (m_hWnd, &ps); } break; case WM_CHAR: OnKeyPress ( (int)wParam, LOWORD(lParam) ); break; case WM_KEYDOWN: OnKeyDown ( (int)wParam ); break; case WM_KEYUP: OnKeyUp ( (int)wParam ); break; case WM_NCDESTROY: OnPreDestroy (); m_hWnd = NULL; break; case WM_DESTROY: OnDestroy (); if (m_isMainWnd) { // ::MessageBox (0, _T("callling PostQuitMessage(0)"), _T(""), 0); ::PostQuitMessage (0); } break; case WM_SIZE: { int cx, cy; cx = LOWORD(lParam); cy = HIWORD(lParam); OnResize (cx, cy); } break; case WM_SETFOCUS: OnGotFocus (); break; case WM_KILLFOCUS: OnLostFocus (); break; case WM_COMMAND: OnCommand ( LOWORD(wParam) ); break; case WM_CONTEXTMENU: OnContextMenu ( ); break; case WM_CLOSE: { BOOL cancel = FALSE; OnClose (cancel); if (cancel == FALSE) DestroyWindow (m_hWnd); } break; case WM_DROPFILES: OnDropFiles ((HDROP)wParam); break; default: return ::DefWindowProc (m_hWnd, msg, wParam, lParam); } return 0; }