CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Feb 2009
    Posts
    56

    Question Tooltip display fails

    PHP Code:
    void CMyToolTip::InitToolTip(HWND hParentWnd)
    {
        if(
    m_toolTip.m_hWnd)
        {
            
    m_toolTip.Create(CWnd::FromHandle(hParentWnd),WS_POPUP|TTS_BALLOON);
            
    m_toolTip.Activate(FALSE);
        }
    }

    void CMyToolTip::SetToolTipText(LPCTSTR lpToolTipTxtHWND hParentWndBOOL bActivate)
    {
        if(
    NULL==lpToolTipTxt) return;
        
    InitToolTip(hParentWnd);
        if(
    0==m_toolTip.GetToolCount())
        {
            
    CRect rcPic
            ::
    GetClientRect(hParentWnd,&rcPic);
            
    m_toolTip.AddTool(CWnd::FromHandle(hParentWnd), lpToolTipTxt, &rcPic,1);
        }
        
    m_toolTip.Activate(bActivate);
        
    m_toolTip.UpdateTipText(lpToolTipTxt,CWnd::FromHandle(hParentWnd),1);

    I have tried the above code to display a balloon tooltip when my mouse is over the picture control but it doesn't show me anything at all. Could you help me ?

    Thanks
    -----

  2. #2
    Join Date
    Apr 2009
    Location
    Cochin
    Posts
    83

    Smile Re: Tooltip display fails

    Picture control? are you refering to a canvas control or Any other like a Bitmap blittted on Static or so??

    Anyways, you've defined the function, and it seems Okay for me.... (I havent compiled)..

    You should need to display the Tooltip, when a Mousehover is occured on the Picture('s) Control.. right?

    If so, you should have to Call this function from the WM_MOUSEHOVER mesage handler of the Picture('s) Control
    "I studied everything but never topped. Today, toppers of the world's best universities are my employees"

    -William Henry Gates (Bill Gates)

  3. #3
    Join Date
    Feb 2009
    Posts
    56

    Re: Tooltip display fails

    static control that is to hold a bitmap with frame/etch/bitmap etc or say a bitmap control

    I have declared a variable m_pic and I get the handle to this bitmap easily m_pic.hWnd hehehe
    Handling mouse messages is fine, only the tooltip doesn't show up and I am really LONG long for it.

    What is wrong ?
    Last edited by yuenqi; May 23rd, 2009 at 05:48 AM.
    -----

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tooltip display fails

    Check your if statement in your InitToolTip.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Feb 2009
    Posts
    56

    Re: Tooltip display fails

    Thanks I see m_hWnd=0x0000000
    How should I fix this ?
    -----

  6. #6
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tooltip display fails

    Your "m_toolTip.Create" creates the tooltip, so you want something like:
    Code:
    void CMyToolTip::InitToolTip(HWND hParentWnd) 
    { 
        if(!m_toolTip.m_hWnd) 
        { 
            m_toolTip.Create(CWnd::FromHandle(hParentWnd),WS_POPUP|TTS_BALLOON); 
            m_toolTip.Activate(FALSE); 
        } 
    }
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  7. #7
    Join Date
    Feb 2009
    Posts
    56

    Re: Tooltip display fails

    Sorry,
    if(!m_toolTip.m_hWnd)
    was what I had in my original source code, the above snip was copied incorrectly. I dont see the balloon display when mouse is over. I don't know why.
    -----

  8. #8
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tooltip display fails

    Can you post a small demo project with the problem? Remove temporary files.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  9. #9
    Join Date
    Feb 2009
    Posts
    56

    Re: Tooltip display fails

    I will send you in email Ok ? no other information except deed for help on this problem is included
    -----

  10. #10
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tooltip display fails

    ok, but why not post it on the forum, so other members might also take a look at it?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  11. #11
    Join Date
    Feb 2009
    Posts
    56

    Re: Tooltip display fails

    Ok, I will but not now, because I am very far away from home and I don't have the source code included in my usb to extract up here.

    Later!
    -----

  12. #12
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Tooltip display fails

    One other thing, did you add a call to RelayEvent?
    Something along the lines like:
    Code:
    BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
    {
    	m_toolTip.RelayEvent(pMsg);
    
    	return CWnd::PreTranslateMessage(pMsg);
    }
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  13. #13
    Join Date
    Feb 2009
    Posts
    56

    Re: Tooltip display fails

    Thank you very much for your help
    But I have to tell you that your help is yet to be sufficient to make the program work. I have to save my class's handle for use in my dialog. That is 1:1 I mean.
    -----

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured