<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visual C++ Tips &#187; EnableToolTips</title>
	<atom:link href="http://weseetips.com/tag/enabletooltips/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>How to enable tooltip for your dialog controls?</title>
		<link>http://weseetips.com/2008/04/28/how-to-enable-tooltip-for-your-dialog-controls/</link>
		<comments>http://weseetips.com/2008/04/28/how-to-enable-tooltip-for-your-dialog-controls/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 17:44:44 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[MFC]]></category>
		<category><![CDATA[EnableToolTips]]></category>
		<category><![CDATA[OnToolTipNotify]]></category>
		<category><![CDATA[ON_NOTIFY_EX_RANGE]]></category>
		<category><![CDATA[tooltip]]></category>
		<category><![CDATA[TTN_NEEDTEXT]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=87</guid>
		<description><![CDATA[Have a number of controls in your dialog. May be a single line of tooltip will add beauty to it. So how can you add tooltips for the controls in your dialog? Its easy. Just follow the steps. Basically you&#8217;ve to enable tooltips by calling EnableToolTips() and then handle the TTN_NEEDTEXT message in your dialog. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
Have a number of controls in your dialog. May be a single line of tooltip will add beauty to it. So how can you add tooltips for the controls in your dialog? Its easy. Just follow the steps.</p>
<p><img class="alignnone size-medium wp-image-12" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
Basically you&#8217;ve to enable tooltips by calling <span style="color:#0000ff;">EnableToolTips()</span> and then handle the <span style="color:#0000ff;">TTN_NEEDTEXT</span> message in your dialog. When its time to show a tooltip, windows will send you the <span style="color:#0000ff;">TTN_NEEDTEXT</span> message with control&#8217; handle and you&#8217;ve to specify the tooltip text to be shown. From handle you can get Dialog control ID. Once you have the control ID, you can specify which tooltip have to be shown for that control. See it step by step. I assume you use MFC. Eventhough you follow the tradition style, just go through the steps, you can easily grasp it.</p>
<p>1) Call <span style="color:#0000ff;">EnableToolTips()</span> in yout dialog initialize function. The best place is in dialog initialization routine &#8211; <span><span style="color:#0000ff;">CDialog::OnInitDialog()</span>.</span><br />
<span>2) Now add message handler for </span><span style="color:#0000ff;">TTN_NEEDTEXT</span> in messagemap. The following codesnippet enables tooltip notification for all controls in your dialog.</p>
<pre>BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
    ...
    ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()</pre>
<p>3) Now declare the tooltip handler in your header as follows.</p>
<pre>afx_msg BOOL OnToolTipNotify( UINT id,
                              NMHDR* pNMHDR,
                              LRESULT* pResult );</pre>
<p>4) Now define the tooltip handler in your cpp file as follows</p>
<pre>BOOL CDialogDlg::OnToolTipNotify( UINT id,
                                  NMHDR * pNMHDR,
                                  LRESULT * pResult )
{
    // Get the tooltip structure.
    TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;

    // Actually the idFrom holds Control's handle.
    UINT CtrlHandle = pNMHDR-&gt;idFrom;

    // Check once again that the idFrom holds handle itself.
    if (pTTT-&gt;uFlags &amp; TTF_IDISHWND)
    {
        // Get the control's ID.
        UINT nID = ::GetDlgCtrlID( HWND( CtrlHandle ));

        // Now you have the ID. depends on control,
        // set your tooltip message.
        switch( nID )
        {
        case IDC_BUTTON1:
                // Set the tooltip text.
                pTTT-&gt;lpszText = _T("First Button");
            break;

        case IDC_BUTTON2:
            // Set the tooltip text.
            pTTT-&gt;lpszText = _T("Second Button");
            break;

        default:
            // Set the tooltip text.
            pTTT-&gt;lpszText = _T("Tooltips everywhere!!!");
            break;
        }

        return TRUE;
    }

    // Not handled.
    return FALSE;
}</pre>
<p><img class="alignnone size-medium wp-image-51" src="http://weseetips.files.wordpress.com/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/04/28/how-to-enable-tooltip-for-your-dialog-controls/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

