Sign in to follow this  
Followers 0
TalivanIBM

Set more than Two images in subitem Listview

4 posts in this topic

I'm trying to put 3, 4, 6 icons in a subitem listview, but the icon only change, i would see all the icons in the same subitem.

Exemple

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $listview, $hImage
    Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList AddIcon", 400, 300)
    $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($listview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($listview, "Column 1", 120)
    _GUICtrlListView_AddColumn($listview, "Column 2", 100)
    _GUICtrlListView_AddColumn($listview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 1, 2)

    _GUICtrlListView_SetItemImage($listview, 0, 1, 2)           ---
    _GUICtrlListView_SetItemImage($listview, 0, 2, 2)           ---
    _GUICtrlListView_SetItemImage($listview, 0, 3, 2)           ---
    _GUICtrlListView_SetItemImage($listview, 0, 4, 2)           ---
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites



I don't know how to do that but you could just add extra columns for the icons maybe.

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $listview, $hImage
    Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList AddIcon", 400, 300)
    $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($listview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($listview, "Column 1", 120)
    _GUICtrlListView_AddColumn($listview, "", 18)
    _GUICtrlListView_AddColumn($listview, "", 18)
    _GUICtrlListView_AddColumn($listview, "", 18)
    _GUICtrlListView_AddColumn($listview, "", 18)
    _GUICtrlListView_AddColumn($listview, "Column 2", 100)

    _GUICtrlListView_AddColumn($listview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 5, 1)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 2, 6)
    _GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 5,1)

    _GUICtrlListView_SetItemImage($listview, 0, 1, 3)
    _GUICtrlListView_SetItemImage($listview, 0, 2, 4)
    _GUICtrlListView_SetItemImage($listview, 0, 3, 1)
    _GUICtrlListView_SetItemImage($listview, 0, 4, 2)
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc ;==>_Main

Otherwise you would need to create an owner drawn listview, or a virtual listview.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

That's good, but i'm asking if in the same column can be more than 2 icons, but your reply says to me, no.

Share this post


Link to post
Share on other sites

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $hListView
_Main()
Func _Main()
    Local $GUI, $hImage, $hDC, $hBackDC, $hBitmap, $hBackSv, $hIcon1, $hIcon2
    $GUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $hListView = _GUICtrlListView_Create($GUI, "Column 1 | Column 2", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState()

    $hImage = _GUIImageList_Create(32,16)
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)
    $hDC = _WinAPI_GetDC(0)
    $hBackDC = _WinAPI_CreateCompatibleDC($hDC)
    $hBitmap = _WinAPI_CreateSolidBitmap($hListView, $COLOR_WHITE, 32, 16)
    $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
    $hIcon1 = _WinAPI_LoadShell32Icon(2)
    $hIcon2 = _WinAPI_LoadShell32Icon(23)
    _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon1, 0, 0, 0, 0, 3)
    _WinAPI_DrawIconEx($hBackDC, 16, 0, $hIcon2, 16, 16, 0, 0, 3)
    _GUIImageList_Add($hImage, $hBitmap)
    _WinAPI_DestroyIcon($hIcon1)
    _WinAPI_DestroyIcon($hIcon2)
    _WinAPI_SelectObject($hBackDC, $hBackSv)
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_DeleteDC($hBackDC)
    _GUICtrlListView_AddItem($hListView, "Item", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Subitem", 1)

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

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