Introduction
If you use Windows 2000, you may have noticed a special tooltip that is used in some instances. At least one spot where it is displayed is after making a dial-up network connection.
CXInfoTip
is a simple control that attempts to reproduce this tooltip. It supports multi-line text (separated with a '\n') and an icon. The control can be used as a normal tooltip for controls or as an immediate popup data tip. It is not a direct replacement for CTooltip
. The control itself is in the source files: CXInfoTip.h and CXInfoTip.cpp.
To use the control, create it and either call the immediate Show()
method or add tools using AddTool()
. If AddTool()
is used then the RelayEvent()
method must be called from the parent window's overridden PreTranslateMessage()
.
To use the control, add a CXInfoTip
member variable to the class.
CXInfoTip m_Tip;
For dialogs, create it in OnInitDialog()
. For other windows create it in OnCreate()
.
m_Tip.Create(this);
To show an immediate tooltip, call the Show()
method.
m_Tip.Show(_T("This is a toolip!"), CPoint(100, 100));
To show normal tooltips, use AddTool()
for each control and call RelayEvent()
from PreTranslateMessage()
.
m_Tip.AddTool(GetDlgItem(IDOK),
_T("This is the OK button!"), m_TooltipIcon);
....
BOOL CInfoTipTestDlg::PreTranslateMessage(MSG* pMsg)
{
m_Tip.RelayEvent(pMsg);
...
}
Methods
-
CInfoTip::Create
BOOL Create (CWnd * pParentWnd)
Creates the tooltip control.
Return value
TRUE
on success, FALSE
otherwise
Parameters
-
CInfoTip::AddTool
void AddTool(CWnd *pWnd, LPCTSTR szTooltipText, HICON hIcon = NULL)
Adds a tool.
Return value
None
Parameters
pWnd
Pointer to the tool window.
szTooltipText
Text to display in the tooltip for the window. Separate multiple lines with a '\n'.
hIcon
Icon to display in the tooltip or NULL
for no icon.
-
CInfoTip::RemoveTool
void RemoveTool(CWnd *pWnd)
Removes a tool.
Return value
None
Parameters
-
CInfoTip::SetIcon
void SetIcon(HICON hIcon)
Sets the icon to show for immediate tooltips.
Return value
None
Parameters
-
CInfoTip::SetShowDelay
void SetShowDelay(int nDelay)
Adjusts the delay before a tooltip is displayed.
Return value
None
Parameters
nDelay
Delay in milliseconds.
-
CInfoTip::SetFont
void SetFont(CFont *pFont)
Sets the tooltip text font.
Return value
None
Parameters
pFont
Pointer to the font.
-
CInfoTip::RelayEvent
void RelayEvent(LPMSG lpMsg)
Relays mouse events to the control. If AddTool()
is used, then this method must be called from PreTranslateMessage()
.
Return value
None
Parameters