Sign in to follow this  
Followers 0
Kogmedia

ListView Text & Picture?

4 posts in this topic




use GUICtrlSetImage after GUICtrlCreateListViewItem

I didn't know that and tried to code a demo, but it's not working. How do you get the icons to show?

#include <GUIConstants.au3>

GUICreate("listview items", 250, 250, 200, 200)

$listview = GUICtrlCreateListView("  col1  |  col2  |  col3  ", 10, 10, 230, 160, $LVS_ICON, $LVS_EX_SUBITEMIMAGES)
$button = GUICtrlCreateButton("Value?", 75, 180, 100, 30)
$item1 = GUICtrlCreateListViewItem("item1/1|col1/2|col1/3", $listview)
$item2 = GUICtrlCreateListViewItem("item2/1|col2/2|col2/3", $listview)
GUICtrlSetImage(-1, "C:\Program Files\AutoIt3\Auto3Lib\Images\Red.ico")
$item3 = GUICtrlCreateListViewItem("item3/1|col3/2|col3/3", $listview)
GUICtrlSetImage(-1, "C:\Program Files\AutoIt3\Auto3Lib\Images\Green.ico")
$item4 = GUICtrlCreateListViewItem("item4/1|col4/2|col4/3", $listview)
GUICtrlSetImage(-1, "C:\Program Files\AutoIt3\Auto3Lib\Images\Blue.ico")
$input1 = GUICtrlCreateInput("", 20, 220, 210, 20)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            GUICtrlSetData($input1, GUICtrlRead(GUICtrlRead($listview)))
        Case $listview
            MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
    EndSwitch
WEnd

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Here's an example :

#include <GUIConstants.au3>
#include <GuiListView.au3>

GUICreate("Uninstall Manager", 350, 440)
$list = GUICtrlCreateListView("Values Found", 5, 5, 340, 430, $LVS_SORTASCENDING)
_GUICtrlListViewSetColumnWidth($list, 0, 315)
GUISetState()

While 1
    Local $ch1
    $ch1 = $ch1 + 1
    $keygen = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    $reg1 = RegEnumKey($keygen, $ch1)
    If @error <> 0 Then
        ExitLoop
    Else
        $reg2 = RegRead($keygen & "\" & $reg1, "DisplayName")
        $reg3 = RegRead($keygen & "\" & $reg1, "UninstallString")
        $reg4 = RegRead($keygen & "\" & $reg1, "DisplayIcon")
        If $reg2 = "" Then
            GUICtrlCreateListViewItem($reg1, $list)
            GUICtrlSetImage(-1, @SystemDir & "\shell32.dll", 131); Xp error icon
        Else
            GUICtrlCreateListViewItem($reg2, $list)
            If StringInStr($reg4, ",0") Then
                $reg4 = StringReplace($reg4, ",0", "")
                GUICtrlSetImage(-1, $reg4, 0)
            ElseIf $reg4 <> "" Then
                GUICtrlSetImage(-1, $reg4, 0)
            ElseIf StringInStr($reg3, '.exe') Then
                $reg5 = StringSplit($reg3, '.exe', 1)
                $reg6 = StringReplace($reg5[1], '"', '')
                $reg6 = $reg6 & '.exe'
                GUICtrlSetImage(-1, $reg6, 0)
            Else
                GUICtrlSetImage(-1, $reg3, 0)
            EndIf
        EndIf
    EndIf
WEnd

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

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