Sign in to follow this  
Followers 0
taotao878

some problems about TreeViewItem

10 posts in this topic

#1 ·  Posted (edited)

How do I create one TreeView as NSIS ?

NSIS's TreeView has tip, when your mouse is hovered over the the TreeView's Item and subitem, the Tip text will be displayed in the Label.

e.g. Manage Current Attachments (1)

post-24544-1193984454_thumb.jpg

Edited by taotao878

Share this post


Link to post
Share on other sites



Thank you very much!

I try it at once.

Share this post


Link to post
Share on other sites

This topic may also help. I will see about getting an example done for you <_<

Sorry, I try it, but I can not solve this problem

Please help me!

Share this post


Link to post
Share on other sites

I have just tried, yet alas, It doesn't work. I am afraid I don't know what else can be done by me. I'll leave it to someone smarter to tell you a fix... If they are willing. <_<

Share this post


Link to post
Share on other sites

Did you look at

GUICtrlSetTip

--------------------------------------------------------------------------------

Sets the tip text associated with a control.

GUICtrlSetTip ( controlID, tiptext [, "title" [, icon [, options]]]]] )

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The actual display on hover is pretty easy, it's harder to come up with a nice way to keep the whole thing (items, text, descriptions) organized. Which is something that I feel the example below is somewhat lacking, but it works.

Using GuiTreeView UDF from latest beta.

#include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1)

$sTitle = "Treeview item descriptions"

$hGui = GUICreate($sTitle, 400, 300, -1, -1, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "SysEvents")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "SysEvents")

Global $aTreeItemText[6][2] = [["Item 1", "This is item 1"], _
                                ["Item 1A", "This is item 1A"], _
                                ["Item 1B", "This is item 1B"], _
                                ["Item 2", "This is item 2"], _
                                ["Item 2A", "This is item 2A"], _
                                ["Item 2B", "This is item 2B"]]

$cTree = GUICtrlCreateTreeView(10,50,200,200, -1, $WS_EX_CLIENTEDGE)
$cTreeItem_1 = GUICtrlCreateTreeViewItem($aTreeItemText[0][0], $cTree)
$cTreeItem_1A = GUICtrlCreateTreeViewItem($aTreeItemText[1][0], $cTreeItem_1)
$cTreeItem_1B = GUICtrlCreateTreeViewItem($aTreeItemText[2][0], $cTreeItem_1)
$cTreeItem_2 = GUICtrlCreateTreeViewItem($aTreeItemText[3][0], $cTree)
$cTreeItem_2A = GUICtrlCreateTreeViewItem($aTreeItemText[4][0], $cTreeItem_2)
$cTreeItem_2B = GUICtrlCreateTreeViewItem($aTreeItemText[5][0], $cTreeItem_2)
Global $hTree = GUICtrlGetHandle($cTree)

GUICtrlCreateGroup(" Description: ", 220, 50, 170, 200)
$cInfoLabel = GUICtrlCreateLabel("", 230, 70, 150, 170)
GUICtrlCreateGroup ("",-99,-99,1,1)

GUISetState()

While 1
    Sleep(1000)
WEnd

Func SysEvents()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MOUSEMOVE
            ;
            $aHwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", MouseGetPos(0), "uint", MouseGetPos(1))
            If (IsDeclared("hTree") = 0) Or ($aHwnd[0] <> $hTree) Then ContinueCase
            $hItem = TreeItemFromPoint($hTree)
            If $hItem = 0 Then
                GUICtrlSetData($cInfoLabel, "")
            Else
                $sTitle = _GUICtrlTreeView_GetText($hTree, $hItem)
                $sDesc = ""
                For $i = 0 To UBound($aTreeItemText)-1
                    If $aTreeItemText[$i][0] = $sTitle Then
                        $sDesc = $aTreeItemText[$i][1]
                        ExitLoop
                    EndIf
                Next
                GUICtrlSetData($cInfoLabel, $sDesc)
            EndIf
    EndSwitch
EndFunc
;Returns handle of tree item under mouse:
Func TreeItemFromPoint($hWnd)
    Local $tMPos = _WinAPI_GetMousePos(True, $hWnd) 
    Return _GUICtrlTreeView_HitTestItem($hWnd, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2))
EndFunc
Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Thank you very much !

I try it, and my problem has been solved.

<_<

Thank again.

Share this post


Link to post
Share on other sites

This great stuff. Thx big time. :)

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