Tool tip on window






4.60/5 (10 votes)
Oct 16, 2001
1 min read

105189

3437
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
- WindowTip.h
- 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 ...
- Use Region instead of Rectangle
- Provide Font, Pen and Brush customization
- To Give a small link on tip