Tooltips for dialog controls

Here's a little trick I use to get tooltips into a dialog quickly. I usually put this code into the OnInitDialog. It allows me to easily add tooltips to any dialog quickly.

Add a member to the CDialog or CWnd derived class in the header like:
CToolTipCtrl    CTTDialog :: m_ToolTip;
In the OnInitDialog or OnInitialUpdate, add:
m_ToolTip.Create (this);
m_ToolTip.Activate (TRUE);

CWnd*    pWnd = GetWindow (GW_CHILD);
while (pWnd)
{
    int nID = pWnd->GetDlgCtrlID ();
    if (nID != -1)
    {
        m_ToolTip.AddTool (pWnd, pWnd->GetDlgCtrlID ());
    }
    pWnd = pWnd->GetWindow (GW_HWNDNEXT);
}
To add a tooltip to a control, just add a string resource using the same ID as the control to get the tip. If I wanted the OK button to have a tip, I would add a string resource for IDOK.

Also do not forget to put the following code to you dialog class:
BOOL CTTDialog :: PreTranslateMessage(MSG* pMsg) 
{
    if (m_hWnd)
    {
        m_ToolTip.RelayEvent (pMsg);
        return CDialog::PreTranslateMessage(pMsg);
    }
    return (FALSE);
}
That's it.

Last updated: 18 May 1998

IT Offers

Comments

  • You want some tomato basil and mozzarella. In esteem of indoor say, these slippers are as light and manueverable as sneakers.

    Posted by Soaceddew on 04/24/2013 08:57am

    Has only released some chic color Democratic Inneva Woven shoes, Nike recently with another way to regurgitate shoes with distinguishable styling to all [url=http://northernroofing.co.uk/roofins.cfm]nike free run[/url] eyes. This brings steadfast issue Free Inneva Woven is a White Label of works in the series, represents shoes Italian made the assurance. Latest Liberated Inneva Woven jet and pornographic are available in two color schemes, to hand-knit Woven vamp in summing-up to infiltrated Italy's [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache free[/url] finest crafts, during the interval gives athletes close to the foot of relieve, the most important opportunity is the goal of Loose 5 configuration, barefoot be aware it resolution allure cannot be ignored. Nike Disburden Inneva Woven SP White Label Wedge on Parade 16 at outlets for everyone the [url=http://northernroofing.co.uk/roofins.cfm]nike free uk[/url] trade name on the shelves, and on sale in narrow sort, interested friends should recompense close publicity to Nike announced the news.

    Reply
  • NikeFree again four shoes eager in autumn and winter wear assuage is perfect ok champion

    Posted by Speadyday on 04/19/2013 08:33am

    Nike Unengaged TR Becoming 2 Safeguard upper of textile materials in line with seasonal requirements, enhances the warmth and durability, and cogitative material, in [url=http://www.nikeskorrea.se/nike-air-max-1-c-41/]air max 1[/url] poor visibility when elucidation and DWR (fast water unruly) coating to achieve breathability while, contract out feet barren in dripping weather. Shoe northern welt on the preferential of the bow down foam enhances foot support and stability. Quality ratio of the Nike Free shoe Groove lay out provides stretchable like literal feet be aware and stability of multi-direction workings while [url=http://www.nikeskoroutlet.se/nike-free-run-2-c-61/]nike free run 2 dam[/url] retaining tenure and shockproof column inherent in training shoes. Lightweight Phylite midsole can unseat and plenty of durability, which increments the utility exponentially outsole, which significantly reduces the manipulate of the shoe. Tail and foot rubber grooves made of environmentally clubby materials, stop to lift its [url=http://www.nikeskoroutlet.se/nike-free-30-v4-c-85/]nike free 3.0 sverige[/url] multi-directional feel on all kinds of route surfaces.

    Reply
  • ComboBoxEx

    Posted by Legacy on 11/02/2003 12:00am

    Originally posted by: Walter Hahn

    This method works perfect but not with the ComboBoxEx control. Any idea how to get it work with this control?

    Reply
  • Cant get this to work in Visual C++.NET (7.0)

    Posted by Legacy on 10/28/2003 12:00am

    Originally posted by: Mike Pliam

    I can't get this to work using C++ 7.0.  I've even tried Corey's fix and putting 'EnableToolTips(TRUE);' in the OnInitDialog() member.
    
    

    Any other's had this problem or know how to fix it?

    Mike

    Reply
  • How to get "&" in ToolTips.

    Posted by Legacy on 11/27/2002 12:00am

    Originally posted by: Rajkumar

    All are fine..But how to get ampersand in tooltips.

    Reply
  • Tooltip useful

    Posted by Legacy on 04/09/2002 12:00am

    Originally posted by: Anand Kumar


    best is yet to be seen

    thanks

    Reply
  • Thanks a lot! I like it!

    Posted by Legacy on 01/30/2002 12:00am

    Originally posted by: GZM

    Your method is very simple!
    
    And she is very useful!
    Thank you!

    Reply
  • tooltips in CstatusBarCtrl ???

    Posted by Legacy on 06/02/2001 12:00am

    Originally posted by: amit gupta

    How can i use the tooltips when i use a CStatusBarCtrl status bar .how should i trap the event when the mouse hovers over a button or a menu item.Problem is that i am unable to use CStatusBar with dialogs.Hence i am using CStatusBarCtrl .

    Can anybody suggest how to use a status bar in a dialog
    Please.I am ready to try anything.
    Waiting...

    Reply
  • Thanks Dave

    Posted by Legacy on 01/30/2001 12:00am

    Originally posted by: Rajiv

    Thanks Dave,
    This helped me in my project!

    Reply
  • ToolTips

    Posted by Legacy on 03/03/1999 12:00am

    Originally posted by: sahu

    It seems to work pretty well, but the tooltip does not show up when a
    control is disabled. Any ideas???

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds