MS-OFFICE STYLE TOOLTIPS IN OWL 2.0 =================================== Introduction ------------ The latest batch of Microsoft applications includes a novel feature called tooltips. With tooltips, as the cursor is moved over the buttons on the toolbar, a small yellow box pops up giving a short description of the button under the cursor. This feature is currently supported by Word 6, Excel 5 and the other Office applications, and will be a feature in the next release of Visual C++ (version 2). I present here a set of C++ classes that allows your existing Borland C++/OWL2 applications to support this functionality today! How to use tooltips ------------------- There are three tooltip classes in this set: TToolTip the tooltip window itself TTipControlBar replacement for TControlBar in your application TTipStatusBar replacement for TStatusBar in your application To be able to use tooltips in your application you will need to create a TToolTip object. The constructor for this object takes no parameters and, should be put into the definition of your main application class: #include "tooltip.h" class TMyApplication : public TApplication { TToolTip tooltip; ... Having done that, you will need to modify your program to use the TTipControlBar and TTipStatusBar classes instead of the normal OWL TControlBar and TStatusBar. The first parameter in the constructor to these new classes is a reference to the TToolTip object created above, to be followed by the parameters passed to the original objects: TControlBar* cb = new TTipControlBar(tooltip, frame); cb->Insert(*new TButtonGadget(CM_FILENEW, CM_FILENEW)); ... TStatusBar *sb = new TTipStatusBar(tooltip, frame, TGadget::Recessed, TStatusBar::CapsLock | TStatusBar::NumLock | TStatusBar::ScrollLock | TStatusBar::Overtype); ... The final stage is to modify the stringtable in your .RC file to include the tooltip messages. To add a tooltip to a particular button, you simply need to modify the hint text message normally displayed on the status bar when the mouse is moved over the button, by adding a "\n" followed by your tooltip text: STRINGTABLE { CM_FILENEW, "Creates a new window\nNew" CM_FILEOPEN, "Opens a window\nOpen" CM_FILECLOSE, "Close this document\nClose" CM_FILESAVE, "Saves this document\nSave" ... Using different Tooltip styles ------------------------------ It is possible to tell the tooltip class to use different styles of presentation. At present there are three styles of presentation: - square border (the default) - rounded border** - shadowed ** The square border and rounded border styles are mutually exclusive To specify one of these styles you need to ensure that the TTooltip object instance is constructed with the style as a parameter. Styles can also be combined together, as the following code (taken from the supplied TEST.CPP file) shows: TooltipApp::TooltipApp () : TApplication("Tooltip Application"), tooltip (Tip::SquareBorder | Tip::Shadow) Limitations in this version --------------------------- - Does not work with TControlGadget objects. This is because the mouse messages are sent to the embedded control, not the control bar - Only works with other TGadget derived objects if they set the hint text on the status bar. You can override the MouseEnter function for the gadget to add this functionality (see the source for TButtonGadget) Getting in touch with the author -------------------------------- I am distributing this code free of charge. I don't ask for anything in return, but if you have any experiences good or bad using this code, I would appreciate hearing from you. Steve Saxon London, England. CIS: 100321,2355