我现在知道 一个窗口的句柄, 有没有方法在他的标题栏上显示一个 tooltip?CToolTipCtrl这个类感觉都是和控件相结合的,各位帮忙啊 

解决方案 »

  1.   

     m_tt.AddTool(this,"Check1");使用this就可以了
    在PreTranslateMessage中GetCursorPos取鼠标位置,如果在标题栏就 m_tt.RelayEvent(pMsg);
    http://blog.csdn.net/leon_founder/archive/2007/07/24/1705200.aspx
      

  2.   

    错了,不需要GetCursorPos,在PreTranslateMessage中用结构体pMsg的参数POINT判断就好了 
      

  3.   

     这哥们,感谢你积极的回答。 但是我现在只有窗口句柄阿, m_tt.AddTool(this,"Check1");这样终究还是需要鼠标移到控件上去的, 我希望移动鼠标到标题栏上的时候,就在鼠标还在标题栏上的时候就显示tooltip,在鼠标显示的位置。
      

  4.   

    这个this是对话框的窗体句柄,移动鼠标到标题栏上他一样要显示,我都试过了的
    其实控件和对话框一样都是一个窗体
      

  5.   

    m_tt.Create(this); 
    m_tt.Activate(TRUE); 
    m_tt.AddTool( this,"Tip Text!");
    m_tt.SetDelayTime(TTDT_INITIAL,1 );
    m_tt.SetDelayTime(TTDT_AUTOPOP,1000);BOOL C***Dlg::PreTranslateMessage(MSG* pMsg) 
    {
        CRect rtWnd,rtTitle;
        GetWindowRect(&rtWnd); //取得窗口的屏幕坐标     CPoint offpt;
        offpt.x = rtWnd.left+GetSystemMetrics( SM_CXFRAME );
        offpt.y = rtWnd.top +GetSystemMetrics( SM_CYFRAME );    rtTitle.left   =   GetSystemMetrics( SM_CXFRAME );   
        rtTitle.top    =   GetSystemMetrics( SM_CYFRAME );   
        rtTitle.right  =   rtWnd.right - rtWnd.left - GetSystemMetrics(SM_CXFRAME);   
        rtTitle.bottom =   rtTitle.top + GetSystemMetrics(SM_CYSIZE); 
        rtTitle.OffsetRect( offpt );  //取得标题栏的屏幕坐标

        CPoint pt; ::GetCursorPos( &pt ); //取得鼠标的屏幕坐标    if( pMsg->message == WM_NCMOUSEMOVE && rtTitle.PtInRect( pt ) )
        {
            this->SetFocus();
            MSG ppMsg;
            ppMsg.hwnd = this->m_hWnd;
            ppMsg.lParam = pMsg->lParam;
            ppMsg.message = pMsg->message;
            ppMsg.time = pMsg->time;
            ppMsg.wParam = pMsg->wParam;
            ppMsg.pt = pt;
            m_tt.RelayEvent(&ppMsg);    }else if( pMsg->message == 0x02A2 ){        MSG ppMsg;
            ppMsg.hwnd = this->m_hWnd;
            ppMsg.lParam = pMsg->lParam;
            ppMsg.message = pMsg->message;
            ppMsg.time = pMsg->time;
            ppMsg.wParam = pMsg->wParam;
            ppMsg.pt.x = 10000;
            ppMsg.pt.y = 10000;
            m_tt.RelayEvent(&ppMsg);
        }
        return CDialog::PreTranslateMessage(pMsg);
    }虽然上面的代码未必满足楼主的要求,但是至少可以显示提示。楼主要在鼠标当前位置显示Tip有一个最大的问题,上面的代码也是这样的,那就是Dialog本身的区域显示。因为标题栏不属于客户区,所以当传了
    this指针以后,tip显示的范围就固定了,只能在标题栏下面(包括菜单、工具栏,如果有的话)。想直接连标题栏上都显示tip不太可能。如果楼主十分想要达到完美的效果,那恐怕只能放弃使用CToolTipCtrl,而是按照CToolTipCtrl的样子自己去写一个类。
    楼主可以参考:http://www.codeproject.com/KB/miscctrl/pptooltip.aspx
    我说的参考是参考里面消息处理和定时机制,处理比较复杂。