Search the Community
Showing results for tags 'GUIToolTip'.
-
Here's a snippet that demonstrates how to use the _GUIToolTip_xxx UDF functions, it's only a brief demo showing some of the techniques to use them. There are no examples in the help file that show how to create them, display them, or use them in general, so I had to figure this out by grabbing snippets here and there from around the internet and seeing how they work. There are several UDFs that utilize the tooltip UDF with explanations on how to use them with the controls that they are made for, for example the ListView and Tabs UDFs have functions that allow you to create tooltips for those controls, but not any general purpose examples are around the forum. It took me a while to find out how to get these to work but once I got the basics down they weren't hard to use at all. This script shows you how to create the tooltip, and how you can color them once they're created. It's heavily commented so it should be easy to follow. Take note of the comment after the _GUIToolTip_SetTipTextColor function, it's important to realize how to color the text correctly. #include <GUIConstantsEx.au3> #include <GUIToolTip.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $MESSAGE = "The following buttons have been clicked" Local $add, $clear, $close, $msg, $mylist Local $hGUI = GUICreate("My GUI list") Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON) ; create a balloon style tooltip control ; turn off visual style for the tooltip otherwise color settings won't work DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hToolTip, "wstr", 0, "wstr", 0) ; if you remove the previous line the tooltip displays normally, but you can't color it $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $hAdd = GUICtrlGetHandle($add) ; we need handles of the controls to use them with the tooltips $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $hClear = GUICtrlGetHandle($clear) $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) Local $hMylist = GUICtrlGetHandle($mylist) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) Local $hClose = GUICtrlGetHandle($close) GUISetState() ; the last number (9) in the below functions indicates that the $iID parameter is a handle to the control and not an identifier of the tooltip ; as well as subclassing the tooltip control _GUIToolTip_AddTool($hToolTip, 0, "Add something to the list", $hAdd, 0, 0, 0, 0, 9) ; this sets a tooltip to the add button _GUIToolTip_AddTool($hToolTip, 0, "This is the close button", $hClose, 0, 0, 0, 0, 9) ; this sets a tooltip to the close button _GUIToolTip_AddTool($hToolTip, 0, "This is the ListBox", $hMylist, 0, 0, 0, 0, 9) ; this sets a tooltip to the list control _GUIToolTip_AddTool($hToolTip, 0, "Clear the list box", $hClear, 0, 0, 0, 0, 9) ; this sets a tooltip to the clear button _GUIToolTip_AddTool($hToolTip, 0, "This is a tooltip for the whole GUI", $hGUI, 0, 0, 0, 0, 9) ; this sets a tooltip to the GUI, and not any control _GUIToolTip_SetTipBkColor($hToolTip, "0xA6EEA4") ; RGB value of the color for the background of the tooltip _GUIToolTip_SetTipTextColor($hToolTip, "0x6835EE") ; ColorRef value (BGR instead of RGB) for the text color of the tooltip While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $add GUICtrlSetData($mylist, "You clicked button No1|") Case $msg = $clear GUICtrlSetData($mylist, "") Case $msg = $close MsgBox(0, "", "the closing button has been clicked", 2) Exit EndSelect WEnd EndFunc ;==>Example