Jump to content
Sign in to follow this  
Wooltown

Tooltip on TreeViewItem

Recommended Posts

Wooltown

Can anyone give an example how to put a tooltip on a TreeViewItem ?

I have tried a lot of combinations, but no success.

Share this post


Link to post
Share on other sites
JRowe

#include <GUIConstants.au3>
#include <GuiTreeView.au3>


$Form1 = GUICreate("Form1", 136, 180, 193, 125)
$TreeView1 = GUICtrlCreateTreeView(8, 8, 121, 161, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_INFOTIP,$WS_GROUP,$WS_TABSTOP))
$TreeView1_0 = GUICtrlCreateTreeViewItem("1", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("1", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("2", $TreeView1_0)
$TreeView1_3 = GUICtrlCreateTreeViewItem("3", $TreeView1_0)
$TreeView1_4 = GUICtrlCreateTreeViewItem("4", $TreeView1_0)
$TreeView1_5 = GUICtrlCreateTreeViewItem("5", $TreeView1_0)
$TreeView1_6 = GUICtrlCreateTreeViewItem("2", $TreeView1)
$TreeView1_7 = GUICtrlCreateTreeViewItem("3", $TreeView1)
$TreeView1_8 = GUICtrlCreateTreeViewItem("4", $TreeView1)
$TreeView1_9 = GUICtrlCreateTreeViewItem("5", $TreeView1)
GUISetState(@SW_SHOW)



While 1
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
    TreeViewToolTip(GUICtrlGetHandle($TreeView1))
WEnd

Func TreeViewToolTip($TreeViewHandle)
    $HotTreeviewItem = TreeItemFromPoint($TreeViewHandle)
    If $HotTreeviewItem <> 0 Then
    $MousePos = GUIGetCursorInfo ()
    ToolTip("TreeView Item ID is " & $HotTreeviewItem, $MousePos[0], $MousePos[1], $MousePos[0] & "," & $MousePos[1], 2)
    ElseIf $HotTreeviewItem = 0 Then
    ToolTip("") 
    EndIf
EndFunc

Func TreeItemFromPoint($hWnd)
    Local $tMPos = _WinAPI_GetMousePos(True, $hWnd)
    Return _GUICtrlTreeView_HitTestItem($hWnd, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2))
EndFunc

Thanks to Siao for the TreeItemFromPoint function.

That gets tooltips per specific items for ya. There's some funkiness there, though :)

Share this post


Link to post
Share on other sites
Wooltown

Thanks, exactly what I was looking for !

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  

×