chenyonken 2017-08-26 10:33 采纳率: 0%
浏览 866

使用MFC的CToolTipCtrl,提示有点异常

不理解为什么ListCtrl下面那里也有一句提示,想去掉下面的那句,怎么做,CToolTipCtrl
部分的代码如下,

图片说明

    m_tip.Create(this);
    EnableToolTips(TRUE);
    m_tip.SetMaxTipWidth(1000);
    m_tip.AddTool(&m_numb,_T("请填入工号"));
    m_tip.AddTool(&m_name,_T("请填入姓名"));
    m_tip.AddTool(&m_dept,_T("请填入部门"));
    m_tip.AddTool(&m_list);
 BOOL CMainWnd::PreTranslateMessage(MSG* pMsg) 
{
    // TODO: Add your specialized code here and/or call the base class
    m_tip.RelayEvent(pMsg);
    return CWnd::PreTranslateMessage(pMsg);
}


 BOOL CMainWnd::SetTipText(UINT id, NMHDR *pTTTStruct, LRESULT *pResult)
{
   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pTTTStruct;
    UINT nID =pTTTStruct->idFrom;
    if (pTTT->uFlags & TTF_IDISHWND)
    {
        // idFrom is actually the HWND of the tool
        nID = ::GetDlgCtrlID((HWND)nID);
        switch(nID)
        {
        case IDC_LIST:
    /*      int nSel=m_list.GetSelectionMark();
            if(nSel<0)
            {
                strcpy(pTTT->lpszText,_T("未选择信息"));
                return TRUE;
            }*/
            if(!m_list.GetSelectedCount())
            {
                strcpy(pTTT->lpszText,_T("未选择信息"));
                return TRUE;
            }
            int nSel=m_list.GetSelectionMark();
            CString  str;
            str.Format("选择的员工信息:\r\n工号:%s \r\n姓名:%s \r\n部门:%s",
                m_list.GetItemText(nSel,0),
                m_list.GetItemText(nSel,1),
                m_list.GetItemText(nSel,2));
            strcpy(pTTT->lpszText,str);
            return TRUE;

        }
    }
    return(FALSE);
}

  • 写回答

1条回答 默认 最新

  • devmiao 2017-08-26 15:57
    关注
    评论

报告相同问题?