OWLNext 7.0
Borland's Object Windows Library for the modern age
|
The TTooltip encapsulates a tooltip control: a small pop-up window that displays a single line of descriptive text giving the purpose of a tool in an application.
The tool is either a window, such as a child window or control, or an application-defined rectangular area within a window's client area.
The tooltip control appears only when the user puts the cursor on a tool and leaves it there for approximately one-half second. It appears near the cursor and disappears when the user clicks a mouse button or moves the cursor away from the tool.
The TTooltip class offers two constructors: one for creating a new control and one for aliasing an existing control.
The following code fragment shows how to create a tooltip control.
Once you have created a tooltip control, you must specify the tools that it will work with. You do this by creating a TToolInfo for each tool. For example, the following code designates a rectangular area of a window as a tool:
When adding a tool, you may provide the text to be used when describing the tool as the last parameter to the constructor of the TToolInfo structure. For example, the following code specifies "Top Left" as the tool tip text:
However, you may opt to provide the text on demand. This allows you to customize the message display to the user. The EV_TTN_NEEDTEXT macro allows you to specify a member function which can provide the text at runtime. The following code fragement illustrates:
The notification handler of the ObjectWindows TDecoratedFrame class enhances the mechanism for specifying the tooltip text by sending a TTooltipEnabler up the command chain. This allows the context window to provide the text even if it did not setup the tool. For example, a grid control in focus can customize the cut, paste and copy tools to specify the data type being manipulated ("Copy Cell" instead of just "Copy").
The EvCommandEnable handler of TDecoratedFrame attempts to provide the tooltip text by looking in two locations: