Sign in to follow this  
Followers 0
Jayson

GUICtrlSetTip in Treeview

29 posts in this topic

#1 ·  Posted (edited)

Hello guys ! I would like to know if it's possible to make a GUICtrlSetTip on some specific item from Treeview filled by a 2d Array.

I made some research and can't find any good example for my project.

Edited by Jayson

Share this post


Link to post
Share on other sites



Jayson,

I am not sure you can have ToolTips in a Treeview. ;)

If you look at these 2 treeviews (the top one created with the UDF; the lower with the native commands) you can see that there is a "tooltip-like" box which shows the text of an item which is too long to fit in the control.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>

Global $aData[3][2] = [[1, 11], [1, 12], [2, 21]]

$hGUI = GUICreate("Test", 500, 500)

$hTV1 = _GUICtrlTreeView_Create($hGUI, 10, 10, 100, 100)

_GUICtrlTreeView_BeginUpdate($hTV1)

$iCurrent_Parent = 0
For $i = 0 To UBound($aData) - 1
    If $aData[$i][0] <> $iCurrent_Parent Then
        $iCurrent_Parent = $aData[$i][0]
        $hParent = _GUICtrlTreeView_Add($hTV1, 0, "Parent " & $aData[$i][0])
    EndIf
    $hChild = _GUICtrlTreeView_AddChild($hTV1, $hParent, "Child " & $aData[$i][1] & " with a very long name")
Next

_GUICtrlTreeView_EndUpdate($hTV1)

$hTV2 = GUICtrlCreateTreeView(10, 200, 100, 100)

$iCurrent_Parent = 0
For $i = 0 To UBound($aData) - 1
    If $aData[$i][0] <> $iCurrent_Parent Then
        $iCurrent_Parent = $aData[$i][0]
        $hParent = GUICtrlCreateTreeViewItem("Parent " & $aData[$i][0], $hTV2)
    EndIf
    $hChild = GUICtrlCreateTreeViewItem("Child " & $aData[$i][1] & " with a very long name", $hParent)
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

As you can only have one tooltip per control (as far as I know) that means that there is no room for a user-defined tooltip - certainly none of my tooltip code can produce one and, like you, I can find nothing on the forum. :)

Looks like this one might be impossible (that should get someone running to prove me wrong!). ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'll keep trying until I give up. First, i'm thinking of creating 2 identical TV. One too small that show the ToolTip of the text too long and one normal. So we could grab the tooltip and match it with any array.

OR

Addind spaces to the ends of every array so it will looks like it doesn't fit and display the tooltip so we can change it after.

Do you think that work around would work ?

Edited by Jayson

Share this post


Link to post
Share on other sites

You might be able to do it with a ToolTip and use the $TVS_TRACKSELECT parameter. Not sure as I haven't tried it.


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

Jayson,

Do not thank me (other than for my searching abilities! :) ), thank a very good coder called Siao: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

Global $aData[3][2] = [["Parent 1", "Child 11 with a very long name"],["Parent 1", "Child 12 with a very long name"],["Parent 2", "Child 21 with a very long name"]]

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xC4C4C4)

$hTV1 = _GUICtrlTreeView_Create($hGUI, 10, 10, 150, 150)

_GUICtrlTreeView_BeginUpdate($hTV1)

$sParent = ""
For $i = 0 To UBound($aData) - 1

    ConsoleWrite($aData[$i][0] & @CRLF)

    If $aData[$i][0] <> $sParent Then
        $sParent = $aData[$i][0]
        $hParent = _GUICtrlTreeView_Add($hTV1, 0, $aData[$i][0])
    EndIf
    $hChild = _GUICtrlTreeView_AddChild($hTV1, $hParent, $aData[$i][1])
Next

_GUICtrlTreeView_EndUpdate($hTV1)

$hTV2 = GUICtrlCreateTreeView(10, 200, 150, 150)
$hTV2_Handle = GUICtrlGetHandle($hTV2)

$sParent = ""
For $i = 0 To UBound($aData) - 1
    If $aData[$i][0] <> $sParent Then
        $sParent = $aData[$i][0]
        $hParent = GUICtrlCreateTreeViewItem($aData[$i][0], $hTV2)
    EndIf
    $hChild = GUICtrlCreateTreeViewItem($aData[$i][1], $hParent)
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MOUSEMOVE
            SetTip()
    EndSwitch
WEnd

Func SetTip()

    $aHwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1))
    Switch $aHwnd[0]
        Case $hTV1, $hTV2_Handle

            $tMPos = _WinAPI_GetMousePos(True, $aHwnd[0])
            $hItem = _GUICtrlTreeView_HitTestItem($aHwnd[0], DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2))

            If $hItem = 0 Then
                ToolTip("")
            Else
                ToolTip(_GUICtrlTreeView_GetText($aHwnd[0], $hItem))
            EndIf
    EndSwitch

EndFunc

Enjoy! ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba,

I might not get what that code does because it still doing the same thing as your other code ;)

Share this post


Link to post
Share on other sites

Jayson,

Do you not get a ToolTip with the name of the item you are hovering over - as well as the normal "full length" tooltip if the item is too long? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba,

Not at all it just show the tooltip because the text if too long not the other one ;)

Share this post


Link to post
Share on other sites

Jayson,

What OS and AutoIt version do you use?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba,

I'm using W7 x64 with AutoIT version 3.3.6.1

Share this post


Link to post
Share on other sites

Jayson,

Try increasing the width of the 2 treeviews to 250 so the "full length" tooltip is not used - do you get the mouse based ToolTip then?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba,

I increased the width but i still don't see the mouse tooltip. That's pretty strange.

Share this post


Link to post
Share on other sites

Jayson,

Please run the ToolTip example from the Help file - do you see it then?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Melba,

It works with these example. ToolTip and GUICtrlSetTip is showing correctly but not with the code you showed me.

Edited by Jayson

Share this post


Link to post
Share on other sites

I am running Win7 x86 and it's working ok for me. The only problem I found with the code is that the tooltip is very persistent and takes some work to get rid of it from every screen. As soon as you leave the treeview window, the tooltip tends to get stuck, but it IS working on x86 Windows.


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

So this might being a bug then ?

Share this post


Link to post
Share on other sites

It's not an AutoIt bug because the native control doesn't support tooltips like you want to use. It's an issue with Siao's function when it's used on x64 systems and since that is not even a standard UDF function then it does not belong in Bug Reports either so don't report it. Someone will figure out the solution and post it, I'm sure but it will have to be someone who can test it on x64 and that's not going to be me. I don't load x64 versions of any operating system.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

GEOSoft,

Thank you for your explanation !

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

jayson,

I see GEOSoft just beat me to it! :)

It is an x64 problem - the data structures are not aligning properly when we pass the mouse position to the DLL. ;)

I am at the ragged edge of my knowledge here, but I think I might have a solution. Please replace the SetTip function with this version and see if it works:

Func SetTip()
    
    If @AutoItX64 Then
        ; If running on x64 - convert position data to x64 structure
        Local $tPoint = DllStructCreate("int X;int Y")
        DllStructSetData ( $tPoint, "X", MouseGetPos(0))
        DllStructSetData ( $tPoint, "Y", MouseGetPos(1))        
        Local $tPoint64 = DllStructCreate("int64", DllStructGetPtr($tPoint))
        Local $aHwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "int64", DllStructGetData($tPoint64, 1))
    Else
        ; If running on x86 - use the original structure
        Local $aHwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1))
    EndIf

    Switch $aHwnd[0]
        Case $hTV1, $hTV2_Handle

            $tMPos = _WinAPI_GetMousePos(True, $aHwnd[0])
            $hItem = _GUICtrlTreeView_HitTestItem($aHwnd[0], DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2))

            If $hItem = 0 Then
                ToolTip("")
            Else
                ToolTip(_GUICtrlTreeView_GetText($aHwnd[0], $hItem))
            EndIf
    EndSwitch

EndFunc

How did I do? ;)

M23

Edit: Screwed up the DllStructCreate - told you I was on the edge. Try it now! :shocked:

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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