HRESULT CMenuToolbarBase::ChangeHotItem(CMenuToolbarBase * toolbar, INT item, DWORD dwFlags) { // Ignore the change if it already matches the stored info if (m_hotBar == toolbar && m_hotItem == item) return S_FALSE; // Prevent a change of hot item if the change was triggered by the mouse, // and mouse tracking is disabled. if (m_disableMouseTrack && dwFlags & HICF_MOUSE) { TRACE("Hot item change prevented by DisableMouseTrack\n"); return S_OK; } // Notify the toolbar if the hot-tracking left this toolbar if (m_hotBar == this && toolbar != this) { SetHotItem(-1); } TRACE("Hot item changed from %p %p, to %p %p\n", m_hotBar, m_hotItem, toolbar, item); m_hotBar = toolbar; m_hotItem = item; if (m_hotBar == this) { if (m_isTrackingPopup && !(m_initFlags & SMINIT_VERTICAL)) { // If the menubar has an open submenu, switch to the new item's submenu immediately PopupItem(m_hotItem, FALSE); } else if (dwFlags & HICF_MOUSE) { // Vertical menus show/hide the submenu after a delay, // but only with the mouse. if (m_initFlags & SMINIT_VERTICAL) { DWORD elapsed = 0; SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0); SetTimer(TIMERID_HOTTRACK, elapsed); m_timerEnabled = TRUE; TRACE("SetTimer called with m_hotItem=%d\n", m_hotItem); } } else { TBBUTTONINFO info; info.cbSize = sizeof(info); info.dwMask = 0; int index = GetButtonInfo(item, &info); SetHotItem(index); } } InvalidateDraw(); return S_OK; }
int CUI::DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float *pY) { int Inside = MouseInside(pRect); if(ActiveItem() == pID) { if(!MouseButton(0)) SetActiveItem(0); } else if(HotItem() == pID) { if(MouseButton(0)) SetActiveItem(pID); } else if(Inside) SetHotItem(pID); if(ActiveItem() != pID || !Inside) return 0; if(pX) *pX = (m_MouseX - pRect->x) / Scale(); if(pY) *pY = (m_MouseY - pRect->y) / Scale(); return 1; }
int CUI::DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float *pY) { int Inside = MouseInside(pRect); if(CheckActiveItem(pID)) { if(!MouseButton(0)) SetActiveItem(0); } else if(HotItem() == pID) { if(MouseButton(0)) SetActiveItem(pID); } else if(Inside) SetHotItem(pID); if(!CheckActiveItem(pID)) return 0; if(pX) *pX = clamp(m_MouseX - pRect->x, 0.0f, pRect->w) / Scale(); if(pY) *pY = clamp(m_MouseY - pRect->y, 0.0f, pRect->h) / Scale(); return 1; }
int CUI::DoButtonLogic(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { // logic int ReturnValue = 0; int Inside = MouseInside(pRect); static int ButtonUsed = 0; if(ActiveItem() == pID) { if(!MouseButton(ButtonUsed)) { if(Inside && Checked >= 0) ReturnValue = 1+ButtonUsed; SetActiveItem(0); } } else if(HotItem() == pID) { for(int i = 0; i < 3; ++i) { if(MouseButton(i)) { SetActiveItem(pID); ButtonUsed = i; } } } if(Inside) SetHotItem(pID); return ReturnValue; }
void DLlist::OnMouseLeave() { // TODO: 在此添加消息处理程序代码和/或调用默认值 SetHotItem(-1); Update(m_oldHotItem); m_oldHotItem=-1; m_hotItem=-1; CListCtrl::OnMouseLeave(); }