Sign in to follow this  
Followers 0
BrewManNH

Using the GUIToolTip UDF

11 posts in this topic

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
2 people like this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites



Thanks for sharing !

Is there any way to display a multiline text? (e.g: with @CrLf char)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Here's the same script with multiline tooltip text.

#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

    ; This line will allow the tooltip to show multiple lines. If the line is too long to fit, it will be 
    ; wrapped to the next line. If you add @CRLF to the tip text without this line, it will only display the firstline
    ; of text.
    _GUIToolTip_SetMaxTipWidth($hToolTip, 1000) ;;1000 is only proforma, you can set it longer or shorter

    $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" & @CRLF & "Click this button", $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 " & @CRLF & "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

You have to add _GUIToolTip_SetMaxTipWidth to get it to display multiline text, don't ask me why, but that's how it works. :)

2 people like this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Here is a modified version of the original script, this modification demonstrates that you can use multiple ToolTip controls and have different settings apply to each of them.

#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 $hToolTip1 = _GUIToolTip_Create($hGUI, $TTS_BALLOON) ; create a balloon style tooltip control
    Local $hToolTip2 = _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", $hToolTip1, "wstr", 0, "wstr", 0)
    ; if you remove the previous line the tooltip displays normally, but you can't color it

    ; This line will allow the tooltip to show multiple lines. If the line is too long to fit, it will be
    ; wrapped to the next line. If you add @CRLF to the tip text without this line, it will only display the firstline
    ; of text.
    _GUIToolTip_SetMaxTipWidth($hToolTip1, 1000) ;;1000 is only proforma, you can set it longer or shorter

    $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($hToolTip1, 0, "Add something to the list" & @CRLF & "Click this button", $hAdd, 0, 0, 0, 0, 9) ; this sets a tooltip to the add button
    _GUIToolTip_AddTool($hToolTip1, 0, "This is the close button", $hClose, 0, 0, 0, 0, 9) ; this sets a tooltip to the close button
    _GUIToolTip_AddTool($hToolTip1, 0, "This is the ListBox", $hMylist, 0, 0, 0, 0, 9) ; this sets a tooltip to the list control
    ; Because these tools are added to ToolTip2, the visual style setting doesn't apply on them
    ; Also, because the function _GUIToolTip_SetMaxTipWidth wasn't applied to ToolTip2, the second line for the Clear button won't show.
    _GUIToolTip_AddTool($hToolTip2, 0, "Clear the list box" & @CRLF & "Click this button", $hClear, 0, 0, 0, 0, 9) ; this sets a tooltip to the clear button
    _GUIToolTip_AddTool($hToolTip2, 0, "This is a tooltip " & @CRLF & "for the whole GUI", $hGUI, 0, 0, 0, 0, 9) ; this sets a tooltip to the GUI, and not any control
    _GUIToolTip_SetTipBkColor($hToolTip1, "0xA6EEA4") ; RGB value of the color for the background of the tooltip
    _GUIToolTip_SetTipTextColor($hToolTip1, "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

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

BrewManNH,

Thank you. I made five examples in the help file.

"0xA6EEA4", RGB

_GUIToolTip_SetTipBkColor($hToolTip1, "0xA6EEA4") ; RGB value of the color for the background of the tooltip
_GUIToolTip_SetTipBkColor($hToolTip1, 0xA6EEA4) ; BGR value of the color for the background of the tooltip

Color better

_GUIToolTip_SetTipBkColor($hToolTip1, 0x395A00)
_GUIToolTip_SetTipTextColor($hToolTip1, 0x1EBFFF)

11 examples of added here

Edited by AZJIO

Share this post


Link to post
Share on other sites

Very nice Azjio, this UDF has been lacking in examples and updates.

Without any examples of how to use it, I never tried it before, now that I've got the basics down I can at least see its advantages over the default tooltips for style purposes if nothing else.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Here is an example to use the default Windows tooltip but with a different font :

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Opt("MustDeclareVars", 1)

_Example()

Func _Example()
Local $hGUI, $hTool, $btnAdd, $hFont, $iMsg

#region GUI
    $hGUI = GUICreate("My GUI", 200, 200)
    $btnAdd = GUICtrlCreateButton("Button", 60, 75, 75, 25)
    GUISetState()
#endregion

#region ToolTip
    $hTool = _GUIToolTip_Create($hGUI)
    _GUIToolTip_SetMaxTipWidth($hTool, 1000) ;1000 is only proforma, you can set it longer or shorter << enables multi-lines text

$hFont = _WinAPI_CreateFont(30, 0) ;30px font
_WinAPI_SetFont($hTool, $hFont) ;sets the font to the tooltip

    _GUIToolTip_AddTool($hTool, 0, _
"line 1" & @CrLf & "line 2", _ ;text
GUICtrlGetHandle($btnAdd), _ ;ctrl handle
0, 0, 0, 0, 9) ; this sets a tooltip to the add button
#endregion

    While $iMsg <> $GUI_EVENT_CLOSE
        $iMsg = GUIGetMsg()
    WEnd
EndFunc   ;==>Example

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I was scanning the ToolTipConstants.au3 file and realized that there are constants in there for the AddTool function, but those constants don't match the values in the help file. For example, the help file states that you should use 8 to subclass the tooltip control.

8 - Indicates that the control should subclass the tool's window

But the tooltip constant for that is 16 "Global Const $TTF_SUBCLASS = 0x00000010", in scanning the code for the AddTool function, there's another function in there that converts the incorrect code into the needed code for the tooltip. The author of the tooltip udf used an 8 bit binary code for the settings for the AddTool function which is then read and converted to the necessary values by this function (_GUIToolTip_BitsToTTF) rather than using the constants that were already there to do it. Seems like a long about way to do things if the constants are already provided.

I'd fix this mess if it wouldn't cause script breaking changes in the UDF, but unfortunately it will cause old scripts to break if it's done. I should probably do it anyways and damn the torpedos.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewManNH,

I uploaded the file again. There are now 18 examples of _GUIToolTip_ ...

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Thank you for the wonderful examples. Very nice!

Edited by millisys

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • astrionn
      By astrionn
      So I had this Idea of creating a tooltip which shows me my ping.
      That itself was made quickly and I thought too add a couple features.
      I want the tooltip background to be a different color depending on the ping. (good ping is green, medium ping is yellow,...)
      So how do I color in a tooltip? google brought me to this: 
       
      where in the comments I found this:
      $s = "LOW" ToolTip($s, 0, 0, "Battery Information");, $icon) $H_TOOLTIP1 = WinGetHandle($s) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "") DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 2552550, "int", 0) Sleep(1000) Which I then used in my code with different color codes... Trial and Error brought me these that I wanted to use:
       
      The Problem is if I loop through my code it only sets the color for the 1st loop and then sticks to it.
      The real problem is tho that I don't exactly understand the dllcalls... And I guess that's why it isn't working
      So if someone would be so awesome to explain to me how they work, or at least can give me a list of these parameters then I would really appreciate that and learn something new
      Obviously a solution to my problem is awesome aswell ^^
      I run this under Windows 8.1
      There is my code in a paste.
      https://pastebin.com/q525f7mS
    • Trolleule
      By Trolleule
      Hi,
      i want to display a tooltip when i hover over the listview group. It sounds not difficult but i couldn't find a solution and i searched for autoit as well as for c# :/
      So i came up with a not so pretty solution:
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiToolTip.au3> #include <WinAPI.au3> Global $idListview, $hWndListView Global $hToolTip = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip Global Const $LVN_GROUPINFO = ($LVN_FIRST - 88) Global Const $tagNMLVGROUP = $tagNMHDR & ";int iGroupId;uint iNewState;uint iOldState" ; $LVGS_flags $LVGS_flags Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tInfo, $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom"), $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode ; Case $of?????? ; A Group was clicked <---- I need help with this Case $LVN_GROUPINFO ConsoleWrite("hier" & @CRLF) $tInfo = DllStructCreate($tagNMLVGROUP, $lParam) _DebugPrint("$LVN_GROUPINFO" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->GroupId:" & @TAB & DllStructGetData($tInfo, "iGroupId") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "iNewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "iOldState")) Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; No return value Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then Exit MsgBox($MB_TOPMOST, @ScriptName, 'please run from the editor, thanks', 10) Example() Func Example() Local $aInfo, $hImage, $idListview $ghui = GUICreate("ListView Group COLLAPSIBLE", 400, 300) $idListview = GUICtrlCreateListView("", 30, 20, 354, 218);, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_REPORT, $WS_CLIPSIBLINGS)) $hWndListView = GUICtrlGetHandle($idListview) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) ; Build groups _GUICtrlListView_EnableGroupView($idListview) _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1) ;~ _GUICtrlListView_SetGroupInfo($idListview, 1, "Group 1", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) ; <--- _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2") ;~ _GUICtrlListView_SetGroupInfo($idListview, 2, "Group 2", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) ; <--- _GUICtrlListView_SetItemGroupID($idListview, 0, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 2) _GUICtrlListView_SetItemGroupID($idListview, 2, 2) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Local $apos = _GUICtrlListView_GetGroupRect($idListview, 2, $LVGGR_LABEL) Local $test = GUICtrlCreateLabel("a", 2, 2, 10, 17) Local $val = _WinAPI_GetWindowLong(GUICtrlGetHandle($test), $GWL_STYLE) Local $valex = _WinAPI_GetWindowLong(GUICtrlGetHandle($test), $GWL_EXSTYLE) Local $aha = _WinAPI_CreateWindowEx($valex+$WS_EX_LAYERED, "static", "blabla", $val, $apos[0], $apos[1], 50, 20, $hWndListView) _GUIToolTip_AddTool($hToolTip, $hWndListView, "This is a ToolTip3", $aha) GUISetState(@SW_SHOW) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Short description: I only created a label with CreateWindowEx which i can append to the listview control and layered it with the $WS_EX_Layered flag so it looks like it's transparent. Then i only added a tooltip tool to that created label.
      Hover over the Group 2 text and the Tooltip will be displayed. My question is: does someone know another perhaps much prettier solution?
      Thanks in advance
    • Sucre
      By Sucre
      I turned to Autoit from AHK just because it support WinForm Application so well. The problem often haunts me that all the application in my job is WinForm. And it indeed help my work so much. Great thanks in advance.
      However, I can't get the ToolTip text in the application of my company. Specifically,now I want to get the information about some data, however the information is all displayed in the tooltip on the scatter diagram which is made of those data.
      Is there any advice ? Relative topics I have searched can't get any information about the winform tooltip...
       
    • Trolleule
      By Trolleule
      Hey,
      i can't find a solution, to set the direction of a tool tip.
      Bootstrap demo
      see "Bottom Tooltip", thats what i try to get. Can someone help?
      #include <GUIConstantsEx.au3> #include <GUIToolTip.au3> #include <GuiTab.au3> $hGUI = GUICreate("Built-In Tab Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480) ; Create tabitems For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) $aha = GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") ; #TOOL TIPS# ========================================================================================================================================================================= Global $hToolTip = _GUIToolTip_Create(GUICtrlGetHandle($hTab), BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); ) ; default style tooltip _GUICtrlTab_SetToolTips($hTab, $hToolTip) _GUIToolTip_SetMaxTipWidth($hToolTip, 100) ; this allows multiline tooltips _GUIToolTip_AddTool($hToolTip, 0, "Reset current View.", GUICtrlGetHandle($aha)) ; ===================================================================================================================================================================================== GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • buymeapc
      By buymeapc
      Hey all,
      Hopefully an easy question...if I have a listview with tooltips enabled and I move the mouse cursor off the listview, how can I clear the tooltip? In the reproducer below, the tooltip remains in almost every circumstance - even if I minimize the gui, the tooltip still overlays other windows. I'd like it to be cleared if I'm outside of the listview, ideally.
      Thanks.
      #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("ToolTip test", 250, 200) $idListView = GUICtrlCreateListView("Column 0|Column 1|Column 2", 10, 10, 235, 175, $WS_VISIBLE, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP)) For $i = 0 To 5 GUICtrlCreateListViewItem(StringFormat("Item %s|abc%s|def%s", $i, $i, $i), $idListView) Next GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $IMsg, $iwParam, $ilParam) #forceref $hWnd, $IMsg, $iwParam Local $hwndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $gText, $aPos $hWndListView = $idListView If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hWndListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hwndFrom = HWnd(DllStructGetData($tNMHDR, "hwndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "idFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hwndFrom Case $hWndListView Switch $iCode Case $LVN_HOTTRACK; Sent by a list-view control When the user moves the mouse over an item $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iItem = DllStructGetData($tInfo, "Item") $iSubItem = DllStructGetData($tInfo, "SubItem") If Not ($iItem = -1 Or $iSubItem = -1) Then $sText = _GUICtrlListView_GetItemText($hwndFrom, $iItem, $iSubItem) ToolTip($sText) Else ToolTip("") EndIf Return 1; the item will not be selected. EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc