CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Posts
    72

    tooltips in a dialog

    I want to show tooltips when the user has the cursor over the dialog controls, so firstly I call EnableToolTips(),
    Then I call the tooltipOnNotify, for some reason it only gets into the OnToolTipNotify function for certain controls & won't get into the function when the cursor is over a check box or a static control or a radio button...., so the question is what do I have to do to get the tooltip over all controls
    ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
    ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)

    BOOL CDialog::OnToolTipNotify(UINT id, NMHDR *pNMHDR,LRESULT *pResult)
    {

    TOOLTIPTEXTA *pTTTA = (TOOLTIPTEXTA *)pNMHDR;
    TOOLTIPTEXTW *pTTTW = (TOOLTIPTEXTW *)pNMHDR;
    CString strTipText;
    UINT nID = pNMHDR->idFrom;

    if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
    pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
    {
    // idFrom is actually the HWND of the tool
    nID = ::GetDlgCtrlID((HWND)nID);
    }

    if (nID != 0) // will be zero on a separator
    strTipText.Format("Control ID = %d", nID);

    *pResult = 0;
    if (pNMHDR->code == TTN_NEEDTEXTA)
    {
    lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
    }else //unicode
    {
    _mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
    }

    return TRUE; // message was handled

    }

  2. #2
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    51
    why do not you use CToolTipCtrl. this class is much easier to integrate into your dialog code

  3. #3
    Join Date
    Sep 2003
    Posts
    72
    Can you please show me sample code on how to implement it in my dialog.

    Thanks

  4. #4
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507

  5. #5
    Join Date
    Sep 2003
    Posts
    72
    Thanks alot for that link to the toolTip information, it worked great

    Thanks again

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