bool CAppMenu::OnEvent(const sf::Event &event) { bool handled = false; switch (event.type) { case sf::Event::MouseButtonPressed: { const auto &data = event.mouseButton; sf::Vector2f mousePos(float(data.x), float(data.y)); m_mousePressCaptured = m_frame.contains(mousePos) || (m_isOpen && GetPopupFrame().contains(mousePos)); break; } case sf::Event::MouseButtonReleased: { const auto &data = event.mouseButton; sf::Vector2f mousePos(float(data.x), float(data.y)); if (m_mousePressCaptured) { if (m_frame.contains(mousePos)) { OnMenuClicked(); handled = true; } else if (m_isOpen) { sf::FloatRect popupFrame = GetPopupFrame(); if (popupFrame.contains(mousePos)) { OnPopupClicked(mousePos.x - popupFrame.left, mousePos.y - popupFrame.top); handled = true; } else { m_isOpen = false; } } } m_mousePressCaptured = false; break; } default: break; } return handled; }
LRESULT MainDialog::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { //禁用双击标题栏最大化 if (WM_NCLBUTTONDBLCLK == uMsg) { return 0; } else if (WM_HOTKEY == uMsg) { OnHotkey(wParam, lParam); return 0; } else if (WM_TRAYICON_NOTIFY == uMsg) { OnTrayIconNotify(wParam, lParam); return 0; } else if (WM_MENU_NOTIFY == uMsg) { LPCTSTR pName = (LPCTSTR)wParam; LPCTSTR pSid = (LPCTSTR)lParam; if (pName) { //LOG__(APP, _T("WM_MENU_NOTIFY:%s"),pName); OnMenuClicked(CString(pName), CString(pSid)); } return 0; } else if (WM_TIMER == uMsg) { if (wParam == TIMER_TRAYEMOT) { static BOOL bTrans = FALSE; if (bTrans) { bTrans = FALSE; SetTrayIconIndex(ICON_TRAY_LOGO); } else { bTrans = TRUE; SetTrayIconIndex(-1); } } } else if (WM_ENDSESSION == uMsg) { BOOL bEnding = wParam; if (!bEnding) return 0; module::getMiscModule()->quitTheApplication(); LOG__(APP, _T("MainDialog: WM_ENDSESSION System End Session OK")); } else if (WM_COPYDATA == uMsg) { COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT*)lParam; OnCopyData(pCopyData); } return WindowImplBase::HandleMessage(uMsg, wParam, lParam); }