|
Balloon Tooltip |
|
|
A tool tip is small help-text window
that appears when the cursor pauses over a tool such as a button
or a list box. The tool tip control monitors mouse-movements and
automatically displays a tool tip if the mouse cursor remains motionless
over a tool for a for a predetermined amount of time.
The functionality of the tool tips have been implemented in the CToolTipCtrl MFC
class.You simply have to create
tool tip control and register the tools which you would like to
have tool tips displayed and the text to go with them. The
tooltip control does the rest. Instead of getting the normal
rectangular shaped tooltips in this article we would see a
program which displays balloon shaped tooltips. On positioning
the mouse on any of the controls for a moment a balloon tooltip
appears. To implement the balloon tooltips we have defined a
tipwnd class apart from the normal application, frame window and
dialog class. The tipwnd class has been derived from the CToolTipCtrl
class. The action begins in the mydialog
class. In the OnInitDialog( ) function of this class we
have created the tooltip window by calling CToolTipCtrl::Create(
). This leads to a call to the tipwnd::OnCreate( ). Here we have created an elliptic
region to represent the tooltip window. When the user performs a
mouse or a keyboard operation in the dialog box the message is
caught by the mydialog::PreTranslateMessage( ). Since we want to exercise control over these messages we
have called the tipwnd::RelayEvent( ) function. In the RelayEvent( ) function the most important message that
has to be tackled in WM_MOUSEMOVE. Here if it is ascertained
that the tooltip window should appear then using the SetWindowPos( )
and the ShowWindow( ) function
the elliptical window is displayed. The actual drawing of the
elliptic window and displaying of text within it is done by tipwnd::OnPaint( ) function.![]() Download |