Click to See Complete Forum and Search --> : I need help with tooltips


Balu Snaix
August 16th, 1999, 02:18 AM
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)

kochhar
August 16th, 1999, 02:30 AM
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.

Roger Allen
August 16th, 1999, 03:25 AM
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