Sign in to follow this  
Followers 0
Ace08

Image + listviewitem

6 posts in this topic

uhm guys anyone know how to put an image inside a list view item?

all i have is this code:

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

Opt('MustDeclareVars', 1)

main()

Func main()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)

    $listview = GUICtrlCreateListView("column1|column2|column3  ", 10, 10, 200, 150)
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("Item 1|2|3", $listview)
    $item2 = GUICtrlCreateListViewItem("Item 2|3|1", $listview)
    $item3 = GUICtrlCreateListViewItem("Item 3|1|2", $listview)
    GUISetState()

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc

i have tried GUICtrlSetImage but i can't seem to make it work, i would appreciate it if you can point me out to the right direction also as an added question is it possible to -- say i clicked the column2 header it will rearange the items in the list view can be ascending or descending order?

Thank you so much for the help


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites



See _GUIImageList_Add function Example


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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



Opt('MustDeclareVars', 1)

main()

Func main()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)

    $listview = GUICtrlCreateListView("column1|column2|column3  ", 10, 10, 200, 150)
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("Item 1|2|3", $listview)
 GUICtrlSetImage(-1, @ScriptFullPath, 0)
    $item2 = GUICtrlCreateListViewItem("Item 2|3|1", $listview)
 GUICtrlSetImage(-1, @ScriptFullPath, -1)
    $item3 = GUICtrlCreateListViewItem("Item 3|1|2", $listview)
 GUICtrlSetImage(-1, @ScriptFullPath, -2)
    $item3 = GUICtrlCreateListViewItem("Item 4|5|6", $listview)
 GUICtrlSetImage(-1, @ScriptFullPath, -3)
    $item3 = GUICtrlCreateListViewItem("Item 4|4|4", $listview)
 GUICtrlSetImage(-1, @ScriptFullPath, -4)
    GUISetState()

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc

EDIT: Use #AutoIt3Wrapper_Res_Icon_Add= to add your own icons into EXE and change icon index accordingly in GUICtrlSetImage()

Edited by Zedna

Share this post


Link to post
Share on other sites

@wakillon

Thanks but isn't that a UDF? i always thought its better not to pair UDFs and autoit functions?

@Zedna

Thanks for the sample however i tried doing this

#AutoIt3Wrapper_Icon=app.ico
#AutoIt3Wrapper_Res_Icon_Add=File.ico
#AutoIt3Wrapper_Res_Icon_Add=Unfile.ico
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

main()

Func main()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg

    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)

    $listview = GUICtrlCreateListView("column1|column2|column3  ", 10, 10, 200, 150)
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("Item 1|2|3", $listview)
    GUICtrlSetImage(-1, "Unfile.ico", 0)
    $item2 = GUICtrlCreateListViewItem("Item 2|3|1", $listview)
    GUICtrlSetImage(-1, "Unfile.ico", -1)
    $item3 = GUICtrlCreateListViewItem("Item 3|1|2", $listview)
    GUICtrlSetImage(-1, "Unfile.ico", -2)
    $item3 = GUICtrlCreateListViewItem("Item 4|5|6", $listview)
    GUICtrlSetImage(-1, "Unfile.ico", -3)
    $item3 = GUICtrlCreateListViewItem("Item 4|4|4", $listview)
    GUICtrlSetImage(-1, "Unfile.ico", -4)
    GUISetState()

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc

but this inly shows the 1st 2 icons in the list view item while the others are blank.

sorry but this is my 1st script using Autoit3wrapper

oh and about my 2nd question? is it possible to click the list view item's header like in my sample if i clicked "column2"(2nd column's header) it will rearange the contents of the listviewitem to decending order or ascending?


Work smarter not harder.My First Posted Script: DataBase

Share this post


Link to post
Share on other sites

@wakillon

Thanks but isn't that a UDF? i always thought its better not to pair UDFs and autoit functions?

_GUIImageList_Add is a function you will find in the Helpfile

illustrated by an example where images are inserted inside a list view item ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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