CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Posts
    9

    I need help with tooltips

    Can any guru tell me how i can add tooltip (a little yellow, in common, window with tip that appeares when you hold mouse pointer over thec object for a while)


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

    Re: I need help with tooltips

    To add a Tooltip, simply add the relevant tip in the resource
    file as follows (this is a minor extension of my response to your last
    question):

    Basically, in the main window's OnCreate function:


    UINT nIndicator=ID_SEPARATOR;
    m_wndStatusBar.Create(this);
    m_wndStatusBar.SetIndicators(&nIndicator,1);



    and in the resource file (*.rc): (e.g.)

    STRINGTABLE
    BEGIN
    ID_ZOOM_IN "Zoom In along X-axis\nZoom In"
    ID_ZOOM_OUT "Zoom Out along X-axis\nZoom Out"
    AFX_IDS_IDLEMESSAGE "Ready"
    ID_APP_EXIT "Quit the Application\nExit"
    ID_HELP_ABOUT "Show version and copyright info\nAbout"
    END



    Hope this helps. This example is for a very basic Status bar with
    one pane.







  3. #3
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: I need help with tooltips

    To get tool tips workning for a dialog box etc, you have to add the following steps.

    Add the call

    EnableToolTips(true) ;



    at some point in the relevant dialog box, usually the OnInitDialog() or init function.

    at this function prototype to the class's .h file


    afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT * pResult);



    Add this line to the message map section in the .cpp file


    ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)




    Then add the function :

    BOOL CClassName::OnToolTipNotify(UINT /*id*/, NMHDR *pNMHDR, LRESULT * /*pResult*/)
    {
    TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
    static char tooltiptext[256] = "";

    if (pTTT->uFlags & TTF_IDISHWND)
    {
    // idFrom is actually the HWND of the tool
    UINT nID = ::GetDlgCtrlID((HWND)pNMHDR->idFrom);

    pTTT->lpszText = NULL;

    switch (nID)
    {
    case IDC_GUESS:
    pTTT->lpszText = "Calculate Number of Components";
    break;

    case IDC_RUN:
    pTTT->lpszText = "Run TFA Calculation";
    break;

    case IDC_ABORT_REFINE :
    pTTT->lpszText = "Abort refinement in progress" ;
    break ;

    case IDC_EQUATIONS :
    pTTT->lpszText = "Equations, pKa seeds and calculated pKa values" ;
    break ;

    case IDC_COMPONENTS_LIST :
    pTTT->lpszText = "Species setup (Active, Overlap or Invisible) and spoil results" ;
    break ;
    }

    if (pTTT->lpszText != NULL)
    {
    pTTT->hinst = AfxGetResourceHandle();
    return(TRUE);
    }
    }

    return(FALSE);
    }







    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

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