Using Tooltips On Controls
Using Tooltips On Controls
Using Tooltips On Controls
Author Rui Cruz (and for a part Aart Onkenhout) Date 10-05-2001 A frequently asked question is: how to show tooltips with PowerBuilder. With this tip comes a user-object (n_tooltip) to achieve this using the tooltipcontrol that's available via comctl32.dll. The fundamentals of this control are developed by Rui Cruz. A couple of functions I added to it myself. These ones are described in the remainder of this tip.
First Example
Creating a tooltip
You create a Tooltip-Window by just adding it as an instance variable to your, e.g., window. After this you have to register controls you want to be able to use the Tooltip-Window. You can do this by calling: inv_Tooltip.of_AddTool( DragObject ado_Object, String as_TipText, Integer ai_Flags )
Second example
Update 29-06-2001
of_RemoveTool An idea coming from Jim Egan (TeamSybase): add an of_RemoveTool function. To give the user the opportunity to switch tooltips on and off, a new function was added. To switch the tooltip of for a certain control, call of_RemoveTool. Arguments are the control itself and the identity returned by of_AddTool. So, if you want to remove tooltips, you have to remember the identities returned. Mousemove-event You don't have to add a mousemove event to every control you add a tooltip for, i.e. when two conditions are met: The tool is a control or is defined as a rectangle in the tool's ToolInfo structure. The window associated with the tool is in the same thread as the ToolTip control. If these two conditions are met, messages are relayed automatically to the tooltip control when you set the uFlags field of the ToolInfo structure to TTF_SUBCLASS ( = 16 ).
In other cases, you have to call of_RelayMsg to make mouse-messages be sent to the tooltip control.
Update 25-02-2005
Added coding to show tooltips on a tabular datawindow for every row and column (as I read very often on the PowerBuilder forums). 07-06-2005: Thierry Decamps discovered you have to call of_addtool again after resizing a datawindow otherwise the tooltips won't show up again (i.e. not for all columns). You can add coding for this within the resize event. First call of_RemoveTool then call of_AddTool. Another addition is the possibility to change delaytimes. There are three delaytimes: 1. TTDT_AUTOPOP: Retrieve the amount of time the ToolTip window remains visible if the pointer is stationary within a tool's bounding rectangle. 2. TTDT_INITIAL: Retrieve the amount of time the pointer must remain stationary within a tool's bounding rectangle before the ToolTip window appears. 3. TTDT_RESHOW: Retrieve the amount of time it takes for subsequent ToolTip windows to appear as the pointer moves from one tool to another. Use the function of_SetDelayTime( Integer ai_Duration, Integer ai_Milliseconds ) to set each of these times. Check the updated sample for an example.
Download (PB9)
Tooltip.zip
Download (PB10)
Tooltip.zip