// 键盘事件处理 BOOL CPopupList::OnControlKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { int nItemCount = m_vecItem.size(); if((nChar == VK_UP) && (m_nHoverItem == 0)) // 关闭下拉列表 { OnNcCloseWindow(); return true; }else if((nChar == VK_UP) && (m_nHoverItem > 0)) // 向上移动一项 { m_nHoverItem--; SetItemPoint(); InvalidateRect(NULL); return true; }else if((nChar == VK_DOWN) && (m_nHoverItem < (nItemCount - 1))) // 向下移动一项 { m_nHoverItem++; SetItemPoint(); InvalidateRect(NULL); return true; }else if(nChar == VK_RETURN) // 回车键选择列表项 { SendMessageToParent(m_uMessageID, SELECT_ITEM, m_nHoverItem); return true; } return false; }
// 键盘事件处理 BOOL CPopupList::OnControlKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { int nItemCount = m_vecItem.size(); if((nChar == VK_UP) && (m_nHoverItem == 0)) // 关闭下拉列表 { OnNcCloseWindow(); return true; }else if((nChar == VK_UP) && (m_nHoverItem > 0)) // 向上移动一项 { m_nHoverItem--; SetItemPoint(); InvalidateRect(NULL); return true; }else if((nChar == VK_DOWN) && (m_nHoverItem < (nItemCount - 1))) // 向下移动一项 { m_nHoverItem++; SetItemPoint(); InvalidateRect(NULL); return true; } return false; }
BOOL CDlgPopup::OnNcActivate(BOOL bActive) { if(!bActive && m_bAutoClose) { //CloseWindow(); // 窗口去激活时候改为调用虚函数,正常情况下是关闭窗口,菜单等派生类可以重载进行一些修改 OnNcCloseWindow(); } else { m_bNCActive = bActive; if(m_bNCActive) { } else { m_bTracking = false; m_bIsSetCapture = false; m_bIsLButtonDblClk = FALSE; if(m_bIsLButtonDown) { m_bIsLButtonDown = FALSE; if(m_pControl) { CRect rcControlUpdate; m_pControl->OnLButtonUp(0, CPoint(-1, -1)); m_pControl = NULL; } } else { if(m_pControl) { CRect rcControlUpdate; m_pControl->OnMouseMove(0, CPoint(-1, -1)); m_pControl = NULL; } } } //DrawWindow(); InvalidateRect(NULL); return TRUE; } return TRUE; }