CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

Home >> Visual C++ / C++ >> Controls >> Other Controls >> Tooltip controls


Adding Tooltip to any control in your Dialog (multiline)
Rating:

Ferdinand V. Abne (view profile)
August 12, 1998

This class helps the user in adding tooltip to any control in the dialog. Tooltip information can be more than one line.

  1. Add MFECToolTip.h and MFECToolTip.cpp in your project
  2. In OnInitDialog, call the Create function and add the tooltip information to any control you would like to have.

    For example:
    In SampleDlg.h add a variable

               MFECToolTip m_toolTip;
    

    In SampleDlg.cpp
           SampleDlg::OnInitDialog()
            {
                m_toolTip.Create( this );    // after creating, add the information
                m_toolTip.AddControlInfo( contol_ID, information, background_color, text_color );
                // control ID is of type UINT
                // information is of type CStringArray.
                // background_color and text_color are optional
            }
    
  3. Override the dialog's PreTranslateMessage to handle mouse movement.
    BOOL CToolTipExDlg::PreTranslateMessage( MSG *pMsg )
    {
            if( pMsg->message == WM_MOUSEMOVE )
            {
                    POINT pt = pMsg->pt;
                    ScreenToClient( &pt );
    
                    // this is the only function to call
                    m_toolTip.ShowToolTip( (CPoint)pt );
            }
    
            return CDialog::PreTranslateMessage(pMsg);
    }
    
  4. explicitly show the tooltip in a particular control, call ShowToolTip( controlID ) with control ID as parameter. Make sure you call AddControlInfo() to add information for this control, otherwise no tooltip is displayed.
  5. Delete or remove the existing tooltip information, call RemoveControlInfo( controlID ) and pass the control ID. If not found nothing happens.
  6. So, you can add and remove tooltip at runtime. Try!

(continued)



Download demo project - 58 KB

Download source - 3.4 KB

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
How we can Add MFECToolTip.h and MFECToolTip.cpp in our project ? - Legacy CodeGuru (01/02/2003)
Use the MFC Tooltip Control, it works much simpler. - Legacy CodeGuru (09/18/2002)
it swallows resources - Legacy CodeGuru (08/05/2002)
Well - Legacy CodeGuru (10/19/2001)
How about propertypages - Legacy CodeGuru (07/27/2000)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Intel PDF: Virtualization Delivers Data Center Efficiency
Intel eBook: Managing the Evolving Data Center
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
Symantec eBook: The Guide to E-Mail Archiving and Management
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Seminar: Efficiencies in Hardware/Software Virtualization
HP Webcast: Disaster Recovery Planning
Go Parallel Video: Performance and Threading Tools for Game Developers
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
IBM TCO eKIT: Your IT Budget is Under Attack, Get in Control
IBM Energy Efficiency eKIT: Learn How to Reduce Costs
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Microsoft Article: Silverlight Streaming--Free Video Hosting for All
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
HP Demo: StorageWorks EVA4400
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES