我用 CToolTipCtrl m_openToolTip;动态显示坐标信息,在OnMouseMove里有CString str; 
str.Format("%d %d",point.x,point.y); 
m_openToolTip.UpdateTipText(str,this)可是我想鼠标在此点停留5秒才显示,时间不够不显示,有什么好方法么

解决方案 »

  1.   

    同样在OnMouseMove里加个计时变量进行判断就可以
    int MVStopTime = 0;
    OnMouseMove

         MVStopTime = GetTickCount();
        ..//其它操作,获得位置等
    }OnTimer()
    {
        if(GetTickCount()-MVStopTime>=5000)//5s
        {
            //显示
        }
    }
      

  2.   

    m_openToolTip.SetDelayTime(TTDT_INITIAL, 5000);
      

  3.   

    2楼的可以停留。但是开始闪烁,就是鼠标不动,一会显示,一会不显示
    我要实现的是鼠标移到一点5秒内不动,就一直显示信息,若鼠标移动,重新等5秒钟,和鼠标放在windowsXP文件夹里的文件上类似
    void CToolsView::OnInitialUpdate()
    {
    CView::OnInitialUpdate();
    MVStopTime = 0;
    SetTimer(1, 2000, 0);
    EnableToolTips(TRUE); 
    m_openToolTip.Create(this); 
    m_openToolTip.AddTool( this, "坐标");
    m_openToolTip.SetDelayTime(200);
    m_openToolTip.SetTipTextColor(RGB(5,117, 207));
    m_openToolTip.SetMaxTipWidth(30);
    m_openToolTip.Activate(TRUE);
    // TODO: 在此添加专用代码和/或调用基类
    }void CToolsView::OnMouseMove(UINT nFlags, CPoint point)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    MVStopTime = GetTickCount(); 
    sChunkProp ="...";//或其他信息
    CView::OnMouseMove(nFlags, point);
    }void CToolsView::OnTimer(UINT nIDEvent)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    if(nIDEvent == 1)
    {
    if(GetTickCount()-MVStopTime>=2000)//5s 

    //显示
    m_openToolTip.UpdateTipText(sChunkProp, this);
    MVStopTime =GetTickCount();

    }
    CView::OnTimer(nIDEvent);
    }
      

  4.   

    虽然不能完全实现,但可以参考一下:
    void CViewTooltipView::OnInitialUpdate() 
    {
    CView::OnInitialUpdate();

    // TODO: Add your specialized code here and/or call the base class
    m_openToolTip.Create(this); 
    m_openToolTip.AddTool( this, "坐标"); 
    m_openToolTip.SetDelayTime(TTDT_INITIAL, 5000);//鼠标移动到控件范围5秒后弹出提示框
    m_openToolTip.SetDelayTime(TTDT_AUTOPOP, 0X7FFFFFFF);//提示一直不消失,直到鼠标再次有动作
    m_openToolTip.SetTipTextColor(RGB(5,117, 207)); 
    m_openToolTip.SetMaxTipWidth(200); 
    m_openToolTip.Activate(TRUE); 

    }void CViewTooltipView::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    CString zb;
    zb.Format("坐标:%i,%i",point.x,point.y); m_openToolTip.AddTool( this, zb); 

    CView::OnMouseMove(nFlags, point);
    }BOOL CViewTooltipView::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    m_openToolTip.RelayEvent(pMsg);

    return CView::PreTranslateMessage(pMsg);
    }
      

  5.   

    解决方法是不用CToolTipCtrl,自己写个 CMyToolTipCtrl,,,