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

使用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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器