如何在OnMouseMove事件中出现一个Tooltips,就像金山词霸取词效果 ?现在我已经添加了OnMouseMove事件处理函数了。

解决方案 »

  1.   

    试着Create CStatic,我也没做过,仅仅一个想法。
      

  2.   

    你用Spy++ HOOK它就知道了人家那玩意是个HWND非ToolTip
      

  3.   

    Tooltips,往往是ToolTipCtrl的,但是金山词霸那个不是,是Window模拟的。这个东西很好模拟。
      

  4.   

    用Tooltips实现?
    你不如自己继承对话框,类似MSN/QQ消息提示框。有很多这样的例子。
      

  5.   

    可以用CToolTipCtrl,但如下代码一堆错误。如下代码是从网上找的。 CToolTipCtrl m_cToolTip;    
    HWND hWnd = GetParent();   
    m_cToolTip.Create(hWnd);   
    m_cToolTip.Activate(true);   
    m_cToolTip.AddTool(hWnd,_T("ToolTip"));   
    MSG msg;   
    msg.hwnd = hWnd;   
    msg.message = uMsg;   
    msg.lParam = lParam;   
    msg.wParam = wParam;   
    m_cToolTip.RelayEvent(&msg);
      

  6.   

    自己实现个Dialog,在OnMouseMove事件里实例化,应该可行。
      

  7.   

    我就是想用CToolTipCtrl做一个非常简单的tooltip。不管任何事件,只要在鼠标旁边显示出tooltip就可以,请问有朋友以前做过吗?
      

  8.   

    1.CToolTipCtrl  m_tooltip;//添加类变量,私有变量 
    2.OnInitDialog()中添加 
                                      m_tooltip.Create(this); 
                                      m_tooltip.AddTool(GetDlgItem(IDOK),"点击此处确认退出"); 
                                      m_tooltip.AddTool(GetDlgItem(IDCANCEL),"点击此处确认退出"); 
    3.重载虚函数:PreTranslateMessage(MSG* pMsg) 
                            添加代码: 
                              if ( m_tooltip ) 
                                { 
                                    m_tooltip.RelayEvent( pMsg ); 
                                }
    应该可以吧!
      

  9.   

    对于控件的tooltip可以了。谢。对于RECT类型的坐标区域的tooltip,可能就不是用GetDlgItem来得到需要放置的tooltip了吧。
      

  10.   

    搞了一个例子,好像应该这样,如下代码INITCOMMONCONTROLSEX icc;
    HWND hwndTip;
    TOOLINFO ti;
    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icc.dwICC =ICC_BAR_CLASSES | ICC_TAB_CLASSES | ICC_WIN95_CLASSES ; InitCommonControlsEx(&icc); if(Balloon)//If you have choosen the Boolen Toop Tip will set the Windows style according to that
    {
    hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
    WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP |TTS_BALLOON,
    CW_USEDEFAULT, CW_USEDEFAULT,
    CW_USEDEFAULT, CW_USEDEFAULT,
    hWnd, NULL, hInst,
    NULL);
    }
    else
    { hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
    WS_POPUP | TTS_NOPREFIX |TTS_ALWAYSTIP,
    CW_USEDEFAULT, CW_USEDEFAULT,
    CW_USEDEFAULT, CW_USEDEFAULT,
    hWnd, NULL, hInst,
    NULL);
    } SendMessage(hwndTip,TTM_ACTIVATE,TRUE,0); //Will Active the Tool Tip Control ti.cbSize = sizeof(TOOLINFO);
    ti.uFlags =  TTF_IDISHWND | TTF_SUBCLASS;
    ti.hwnd   = hWnd; //Handle of the window in which the Contol resides
    ti.uId    =(UINT)GetDlgItem(hWnd,id);       //ID of the Cotrol for which Tool Tip will be Displyed
    ti.hinst  = hInst;
    ti.lpszText  = Tip; //Tip you want to Display;
    ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0;  if(!SendMessage(hwndTip,TTM_ADDTOOL,0,(LPARAM)&ti)){ //Will add the Tool Tip on Control
    MessageBox(NULL,L"Couldn't create the ToolTip control.",L"Error",MB_OK); } return TRUE;