Jump to content

Recommended Posts

Posted (edited)

Hello,

i have a problem with a treeview and a given imagelist. To explain the problem i post a snipped of the treeview example from the help file and add an imagelist.

Global $hTreeView

_Main()

Func _Main()

    Local $GUI, $hItem
    Local $IconList
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $IconList = _GUIImageList_Create(16, 16, 3, 3)
    _GUIImageList_SetBkColor ( $IconList, "0xFFFFFF" )
  ; insert icons into Imagelist
    _GUIImageList_AddIcon ( $IconList, @SystemDir & "\shell32.dll", 1); domain icon
    _GUIImageList_AddIcon ( $IconList, @SystemDir & "\shell32.dll", 15); computer icon
    _GUIImageList_AddIcon ( $IconList, @SystemDir & "\shell32.dll", 18); ou icon
    _GUIImageList_AddIcon ( $IconList, @SystemDir & "\shell32.dll", 170); user icon



    $GUI = GUICreate("(UDF Created) TreeView Create", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    _GUICtrlTreeView_SetNormalImageList ( $hTreeView, $IconList )
    
    GUISetState()

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 1 To Random(1, 4, 1)
        $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x),1)
        For $y = 1 To Random(3, 4, 1)
            _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y),2)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

  ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc ;==>_Main

When you click an item, the image from that icon will be changed to the icon with the index 0 from the imagelist. It will be changed back to the original icon when you select another item but it looks not really nice.

Is this a bug or how can i disable this functionality? I've searched the forum but haven't found any solutions...

greetz and thx in advance

Sundance

Edited by Sundance
Posted

TreeView item have a two icon state: selected, non-selected item. Add icon index again, e.g _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x), 1, 1)

Posted

TreeView item have a two icon state: selected, non-selected item. Add icon index again, e.g _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x), 1, 1)

Wow,

thanks rasim. It seems i totally didn't understand the last parameter :-)

greetz

Sundance

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
×
×
  • Create New...