Icon von EXE in TreeView???

  • Kann mir einer sagen wie man ein Icon von einer EXE in ein TreeView bekommt.
    Hier nur ein kleiner Teil meiner Gui.

    Spoiler anzeigen
    [autoit]

    ; Software - Installationsfenster:
    ;---------------------------------
    Global $Progs_GUI = GUICreate("",$gui_width,$gui_child_height,0,0,$WS_CHILD,-1,$main_GUI)
    $Pic_Progs = GUICtrlCreatePic(@ScriptDir & "\Setup\Pics\software.jpg",-1,-1, 800, 600, $WS_EX_TRANSPARENT )
    GUICtrlSetFont(-1,14,600)

    [/autoit] [autoit][/autoit] [autoit]

    ; Erstellen der Buttons:
    ;-----------------------
    Global $Progs_button4 = GUICtrlCreateButton("Alles auswählen",($gui_width -600) / 2,$gui_child_height - 38,90,30)
    GUICtrlSetTip(-1,"Alle Programme auwählen?";)
    GUICtrlSetCursor(-1, 0)
    Global $Progs_button5 = GUICtrlCreateButton("Auswahl löschen",($gui_width -400) / 2,$gui_child_height - 38,90,30)
    GUICtrlSetTip(-1,"Alle gewählten Programme wieder entfernen?";)
    GUICtrlSetCursor(-1, 0)
    Global $Progs_button6 = GUICtrlCreateButton("Installieren",($gui_width -200) / 2,$gui_child_height - 38,90,30)
    GUICtrlSetTip(-1,"Die ausgewählten Programme installieren?";)
    GUICtrlSetCursor(-1, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ;Erstellen des TreeView:
    ;-----------------------
    Global $treeview = GUICtrlCreateTreeView (($gui_width -600) / 2,$gui_child_height - 370,300,210,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_CHECKBOXES),$WS_EX_TRANSPARENT )
    GUICtrlSetBkColor(-1,0xFFFFFF)
    GUICtrlSetFont (-1,10, 400, 2)
    GUICtrlSetCursor(-1, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ;Erstellen der TreeView-Labels:
    ;---------------------
    $Prog1 = GUICtrlCreateTreeViewitem ("Nero 7",$treeview)
    $Prog2 = GUICtrlCreateTreeViewitem ("TuneUp 2007",$treeview)
    $Prog3 = GUICtrlCreateTreeViewitem ("DaViDeo Ultimate",$treeview)

    [/autoit] [autoit][/autoit] [autoit]

    ;Erstellen der TreeView-Icons:
    ;---------------------
    GUICtrlSetImage ($Prog1, "shell32.dll",22)
    GUICtrlSetImage ($Prog2, "shell32.dll",15)
    GUICtrlSetImage ($Prog3, "shell32.dll",14)

    [/autoit] [autoit][/autoit] [autoit]

    ;Vorhandene Programme Deaktivieren
    ;---------------------
    ;If FileExists("C:\Programme\Nero";) then
    ; GUICtrlDelete($Prog1)
    ;EndIf

    [/autoit]

    Edit Bugfix: Spoiler gesetzt

  • Zeile 34-36 zeigen Icons aus der shell32.dll im TreeView an aber wie kann man das in einem TreeView mit dem Bild einer EXE-Datei machen.
    Oder z.B. bmp,jpg oder ico. :)

    • Offizieller Beitrag

    Hi,

    alle oder keinen :

    !!! If use this command on a TreeView/Item or ListView/Item the first time, then all other items will use this icon/image automatically by default !!!
    If you use GUICtrlSetImage on a TreeView or ListView then all items of it will change to this icon/image.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("My GUI with treeview", 350, 215)

    [/autoit] [autoit][/autoit] [autoit]

    $treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
    GUICtrlSetColor(-1, 0x0000C0)
    $displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
    GUICtrlSetColor(-1, 0x0000C0)
    $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
    $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
    $useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
    $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
    $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
    GUICtrlSetImage (-1, "shell32.dll",22)

    [/autoit] [autoit][/autoit] [autoit]

    $startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
    $aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
    GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization
    $compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
    GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN)
    $togglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20)
    $infobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20)
    $statebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20)
    $cancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
    GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
    ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    Case $msg = $togglebutton ; Toggle the bold painting
    If BitAND(GUICtrlRead($generalitem), $GUI_DEFBUTTON) Then
    GUICtrlSetState($generalitem, 0)
    GUICtrlSetState($displayitem, 0)
    Else
    GUICtrlSetState($generalitem, $GUI_DEFBUTTON)
    GUICtrlSetState($displayitem, $GUI_DEFBUTTON)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case $msg = $infobutton
    $item = GUICtrlRead($treeview) ; Get the controlID of the current selected treeview item
    If $item = 0 Then
    MsgBox(64, "TreeView Demo", "No item currently selected")
    Else
    $text = GUICtrlRead($item, 1) ; Get the text of the treeview item
    If $text == "" Then
    MsgBox(16, "Error", "Error while retrieving infos about item")
    Else
    MsgBox(64, "TreeView Demo", "Current item selected is: " & $text) ; $advmsg[0] contains the text and $advmsg[1] the state value of the treeview item
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case $msg = $statebutton
    $item = GUICtrlRead($treeview)
    If $item > 0 Then
    $hItem = GUICtrlGetHandle($item)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", GUICtrlGetHandle($treeview), "int", $TVM_EXPAND, "int", $TVE_TOGGLE, "hwnd", $hItem)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter)
    Case $msg = $generalitem
    GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

    [/autoit] [autoit][/autoit] [autoit]

    Case $msg = $aboutitem
    GUICtrlSetState($compinfo, $GUI_HIDE)
    GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

    [/autoit] [autoit][/autoit] [autoit]

    Case $msg = $compitem
    GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIDelete()
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
    Local $idx

    [/autoit] [autoit][/autoit] [autoit]

    For $idx = $hidestart To $hideend
    GUICtrlSetState($idx, $GUI_HIDE)
    Next
    For $idx = $showstart To $showend
    GUICtrlSetState($idx, $GUI_SHOW)
    Next
    EndFunc ;==>GUIChangeItems

    [/autoit]

    So long,

    Mega

  • Ich habe es gemerkt mit alle oder keinem bei diesem Befehl:
    GUICtrlSetImage

    Meine Frage war ja auch mit welchem Befehl es geht! ?(

    Checkbox , Programmicon ,Programmname in einer Zeile bei einem TreeView!!!

    • Offizieller Beitrag

    Hi,

    dafür gibt es keine "offizielle" Autoit Funktion.

    Du kannst aber mal dies probieren:

    Spoiler anzeigen
    [autoit]


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

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("My GUI with treeview", 350, 215)

    [/autoit] [autoit][/autoit] [autoit]

    Local $idTreeView = GUICtrlCreateTreeView(4, 4, 342, 150, BitOR($TVS_HASBUTTONS, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

    [/autoit] [autoit][/autoit] [autoit]

    ; Parent1
    _GUICtrlTreeViewInsertItem($idTreeView, "Parent1")
    ; Parent2
    Local $hParent2 = _GUICtrlTreeViewInsertItem($idTreeView, "Parent2")
    _GUICtrlTreeViewInsertItem($idTreeView, "Child1", $hParent2)
    _GUICtrlTreeViewInsertItem($idTreeView, "Child2", $hParent2)
    _GUICtrlTreeViewInsertItem($idTreeView, "Child3", $hParent2)
    _GUICtrlTreeViewInsertItem($idTreeView, "Child4", $hParent2)
    ; Parent3
    _GUICtrlTreeViewInsertItem($idTreeView, "Parent3")

    [/autoit] [autoit][/autoit] [autoit]

    ; Set the state icon for Parent2
    _GUICtrlTreeViewSetStateIcon ($idTreeView, $hParent2, @SystemDir & "\user32.dll", 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GUICtrlTreeViewSetStateIcon ($i_treeview, $h_item = 0, $s_iconfile = "", $i_iconID = 0)
    $h_item = _TreeViewGetItemHandle ($i_treeview, $h_item)
    If $h_item = 0 Or $s_iconfile = "" Then Return SetError(1, 1, False)

    [/autoit] [autoit][/autoit] [autoit]

    Local $st_TVITEM = DllStructCreate($s_TVITEMEX)
    If @error Then Return SetError(1, 1, False)

    [/autoit] [autoit][/autoit] [autoit]

    Local $st_icon = DllStructCreate("int")
    Local $i_count = DllCall("shell32.dll", "int", "ExtractIconEx", _
    "str", $s_iconfile, _
    "int", $i_iconID, _
    "ptr", 0, _
    "ptr", DllStructGetPtr($st_icon), _
    "int", 1)
    If $i_count[0] = 0 Then Return 0

    [/autoit] [autoit][/autoit] [autoit]

    Local $h_imagelist = GUICtrlSendMsg($i_treeview, $TVM_GETIMAGELIST, 0, 0)
    If $h_imagelist = 0 Then
    $h_imagelist = DllCall("comctl32.dll", "hwnd", "ImageList_Create", _
    "int", 16, _
    "int", 16, _
    "int", 0x0021, _
    "int", 0, _
    "int", 1)
    $h_imagelist = $h_imagelist[0]
    If $h_imagelist = 0 Then Return SetError(1, 1, False)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSendMsg($i_treeview, $TVM_SETIMAGELIST, 2, $h_imagelist)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $h_icon = DllStructGetData($st_icon, 1)
    Local $i_icon = DllCall("comctl32.dll", "int", "ImageList_AddIcon", _
    "hwnd", $h_imagelist, _
    "hwnd", $h_icon)
    $i_icon = $i_icon[0]

    [/autoit] [autoit][/autoit] [autoit]

    ; Index 0 is invalid for the state image so we add the icon again
    ; to get an index greater than zero.
    If $i_icon = 0 Then
    $i_icon = DllCall("comctl32.dll", "int", "ImageList_AddIcon", _
    "hwnd", $h_imagelist, _
    "hwnd", $h_icon)
    $i_icon = $i_icon[0]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", $h_icon)

    [/autoit] [autoit][/autoit] [autoit]

    Local $u_mask = $TVIF_STATE

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($st_TVITEM, 1, $u_mask)
    DllStructSetData($st_TVITEM, 2, $h_item)
    ; The index needs shifted left 12 bits.
    DllStructSetData($st_TVITEM, 3, BitShift($i_icon, -12))
    DllStructSetData($st_TVITEM, 4, $TVIS_STATEIMAGEMASK)

    [/autoit] [autoit][/autoit] [autoit]

    Return GUICtrlSendMsg($i_treeview, $TVM_SETITEM, 0, DllStructGetPtr($st_TVITEM))
    EndFunc ;==>_GUICtrlTreeViewSetStateIcon

    [/autoit]

    So long,

    Mega

  • Logisch geht das auch mit "Autoit"-Funktionen:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("My GUI with treeview", 350, 215)

    [/autoit] [autoit][/autoit] [autoit]

    $treeview = GUICtrlCreateTreeView(6, 6, 250, 150, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)
    GUICtrlCreateTreeViewitem("CMD", $treeview)
    GUICtrlSetColor(-1, 0x0000C0)
    GUICtrlSetImage(-1, "cmd.exe", 0)
    GUICtrlCreateTreeViewitem("Notepad", $treeview)
    GUICtrlSetImage(-1, "notepad.exe", 0)
    GUICtrlCreateTreeViewitem("Paint", $treeview)
    GUICtrlSetImage(-1, "mspaint.exe", 0)
    GUICtrlCreateTreeViewitem("Regedit", $treeview)
    GUICtrlSetColor(-1, 0x0000C0)
    GUICtrlSetImage(-1, "regedit.exe", 0)
    GUICtrlCreateTreeViewitem("WordPad", $treeview)
    GUICtrlSetImage(-1, "write.exe", 0)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState ()
    Do
    Until GUIGetMsg() = -3

    [/autoit] [autoit][/autoit] [autoit]

    GUIDelete()
    Exit

    [/autoit]

    Gruß
    Holger

    Edit BugFix: Hab mal noch Code-Tags eingefügt, sieht irgendwie freundlicher aus ;)