Click here to Skip to main content
15,881,687 members
Articles / Desktop Programming / MFC
Article

Tool tip on window

Rate me:
Please Sign up or sign in to vote.
4.60/5 (11 votes)
16 Oct 20011 min read 104K   3.4K   34   12
Tooltips for window according to specified rectangular areas of that window

Introduction

In windows world ToolTips are very important from users point of view and developers used to provide this facility to user. As we know that MFC does not provide tool tip for a part of window (It provides tool tips for controls) so this source will help to give tool tip for specified regions of window. This is very useful for those people who deals with drawings because through this they can give tool tip to their drawings.

How to use the source code

Include the following files in your project

  1. WindowTip.h
  2. WindowTip.cpp

First Create the ToolTip window as soon as you create your parent window on that you want to display the tool tip

CWindowTip m_MyTip; // Create the object
m_MyTip.SetDelay(1000); // Set the Display delay
m_MyTip.CreateTipWnd(this); // Create the Window

Now call ShowTip function in mouse move of parent window

m_MyTip.ShowTip(point); // Pass current mouse position

And now add as much tips you want to add by using Following method.

1. Create an object of CTipInfo

2. Set region and text for tip using SetReagion and

SetText

3. Finally add this using AddTip method of CWindowTip

CTipInfo info(CRect(0, 0, 100, 100),
              "Top Left corner of Window");
m_MyTip.AddTip(info);   

// specifies bottom right corner of window
CRect t_rect;
GetClientRect(&t_rect); // Gets the Parent 
                        // Window Client area
t_rect.top = t_rect.bottom - 100 ;
t_rect.left = t_rect.right - 100 ;
info.SetReagion(t_rect);
info.SetText("Bottom Right corner of Window");
m_MyTip.AddTip(info);

// specifies middle area of window
t_rect.top  = t_rect.bottom / 2 - 50;
t_rect.left = t_rect.right / 2 - 50;
t_rect.bottom = t_rect.top + 100;
t_rect.right = t_rect.left + 100;
info.SetReagion(t_rect);
info.SetText("Middle area of window");
m_MyTip.AddTip(info);

How to use Demo project

  • Just double click on ToolTip.exe
  • Double click on window to set the ToolTips
  • Move the mouse to top left, middle and right corner of window and wait for a second.

Future Work ...

  1. Use Region instead of Rectangle
  2. Provide Font, Pen and Brush customization
  3. To Give a small link on tip

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
I am a Software Professional and Currently working in C-DAC (Centre For Development of Advanced Computing). This is a Scientific Socity under ministry of india of Information Technology.
I have completed My B.C.A. Degree with 77% marks, I am certified by microsofr as Microsoft Certified Professional in Visual Basic 6.0(70-176). Currently working on Visual C++ 6.0 and Using MFC support in my Applicaitons.
For Future Studying 3D graphics desinging like OpenGL and DirectX.

Comments and Discussions

 
GeneralMy vote of 2 Pin
Nenad.T13-Jun-11 23:19
professionalNenad.T13-Jun-11 23:19 
GeneralTool l tip on window Pin
elemella lavanya19-Mar-09 1:21
elemella lavanya19-Mar-09 1:21 
QuestionHow can I make It work with CScrollView ? Pin
Laan8222-Oct-08 21:44
Laan8222-Oct-08 21:44 
Hi all,

I'm trying to make this class work in a project that inherit the View class from CscrollView instead of CView what I have to do to make it work?

modified on Thursday, October 23, 2008 6:27 AM

QuestionCan the class show the tips in "multi-line" style? Pin
laohubinbin30-Mar-05 0:52
laohubinbin30-Mar-05 0:52 
AnswerRe: Can the class show the tips in "multi-line" style? Pin
Christopher Stratmann11-Nov-05 0:36
Christopher Stratmann11-Nov-05 0:36 
GeneralRe: Can the class show the tips in "multi-line" style? Pin
urb012324-Nov-07 15:49
urb012324-Nov-07 15:49 
GeneralTool tip doesn't show in Dialog application. Pin
Andrew Fox29-Jan-04 23:07
Andrew Fox29-Jan-04 23:07 
GeneralRe: Tool tip doesn't show in Dialog application. Pin
Andrew Fox29-Jan-04 23:17
Andrew Fox29-Jan-04 23:17 
Generalprevious window blink Pin
IvanhoeJugger3-Feb-03 1:39
IvanhoeJugger3-Feb-03 1:39 
GeneralRe: previous window blink Pin
ags19914-Aug-03 5:29
ags19914-Aug-03 5:29 
GeneralMouse trails Pin
Anonymous31-Oct-02 17:31
Anonymous31-Oct-02 17:31 
GeneralTooltip disappears if bottom right corner Pin
Craig Miller20-Mar-02 9:00
Craig Miller20-Mar-02 9:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.