- BEGIN_MESSAGE_MAP(CTipListCtrl, CListCtrl)
-
- ON_WM_MOUSEMOVE()
- ON_WM_DESTROY()
-
- END_MESSAGE_MAP()
-
-
-
-
- void CTipListCtrl::OnMouseMove(UINT nFlags, CPoint point)
- {
-
-
- if(m_bEnableTips)
- {
- CString str;
- LVHITTESTINFO lvhti;
-
-
- lvhti.pt = point;
- SubItemHitTest(&lvhti);
-
-
- if((lvhti.iItem != m_nItem) || (lvhti.iSubItem != m_nSubItem))
- {
-
- m_nItem = lvhti.iItem;
- m_nSubItem = lvhti.iSubItem;
-
-
-
-
- if((m_nItem != -1) && (m_nSubItem != -1))
- {
-
-
- str = GetItemText(m_nItem ,m_nSubItem);
- m_toolTip.AddTool(this, str);
-
- m_toolTip.Pop();
- }
- else
- {
- m_toolTip.AddTool(this, _T("双击记录可查看人员详细信息并对其修改"));
-
- m_toolTip.Pop();
- }
-
- }
- }
-
- CListCtrl::OnMouseMove(nFlags, point);
- }
-
- BOOL CTipListCtrl::PreTranslateMessage(MSG* pMsg)
- {
-
- if(::IsWindow(m_toolTip.GetSafeHwnd()))
- {
- m_toolTip.RelayEvent(pMsg);
- }
-
- return CListCtrl::PreTranslateMessage(pMsg);
- }
-
- void CTipListCtrl::OnDestroy()
- {
- CListCtrl::OnDestroy();
-
-
-
- m_toolTip.DestroyWindow();
- m_toolTip.Detach();
- }
-
- BOOL CTipListCtrl::EnableTips()
- {
- EnableToolTips(TRUE);
-
- m_bEnableTips = m_toolTip.Create(this, TTS_ALWAYSTIP);
-
- if(m_bEnableTips)
- {
- m_toolTip.Activate(TRUE);
- m_toolTip.SetDelayTime(TTDT_INITIAL, 0);
- }
-
- return m_bEnableTips;
- }
VC/MFC 在ListCtl 控件中随鼠标移动提示单元格信息,布布扣,bubuko.com
VC/MFC 在ListCtl 控件中随鼠标移动提示单元格信息