Search the Community
Showing results for tags 'imagelist'.
-
Hello all. It's me again. I've got a ListView with an associated ImageList to display icons. What I seem to be hung up on is how to keep the ImageList updated to match the ListView as the latter changes. I thought it was the case that the indices of the items in the ListView and those in the ImageList just needed to match. So, for example, if I: Delete an item from the ListView [_GUICtrlListView_DeleteItem()], and also delete the image at the matching index in the ImageList [_GUIImageList_Remove()]. Then add a new item to the end of the ListView [_GUICtrlListView_AddItem()], and correspondingly add an image at the end of the ImageList [_GUIImageList_AddIcon()] Shouldn't everything stay in sync? Here's the code I thought would work: #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <FontConstants.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> Test() func Test() $gui = GUICreate("Test", 400, 300) ; Create ListView $lv = _GUICtrlListView_Create($gui, "", 10, 10, 380, 240, $LVS_DEFAULT) _GUICtrlListView_AddColumn($lv, "Col1", 50) _GUICtrlListView_AddColumn($lv, "Col2", 50) for $i = 0 to 2 $s = StringFormat("%d,1", $i+1) _GUICtrlListView_AddItem($lv, $s, $i) $s = StringFormat("%d,2", $i+1) _GUICtrlListView_AddSubItem($lv, $i, $s, 1) next ; Add ImageList $img_list = _GUIImageList_Create(16, 16, 5, 3) for $i = 0 to 2 $ico = StringFormat("%d.ico", $i+1) _GUIImageList_AddIcon($img_list, $ico) next _GUICtrlListView_SetImageList($lv, $img_list, 1) ; $btn = GUICtrlCreateButton("Test", 10, 260, 60, 30) GUISetState(@SW_SHOW) HotKeySet("^q", Quit) ; Loop until the user exits. while True switch GUIGetMsg() case $GUI_EVENT_CLOSE Exit case $btn ; Remove 2nd list item and image _GUICtrlListView_DeleteItem($lv, 1) _GUIImageList_Remove($img_list, 1) ; Add new item to end of ListView $idx = _GUICtrlListView_AddItem($lv, "foo") _GUICtrlListView_AddSubItem($lv, $idx, "bar", 1) ; Add new image to end of ImageList _GUIImageList_AddIcon($img_list, "5.ico") endswitch wend GUIDelete() endfunc func Quit() Exit endfunc What seems to happen is that when the new item is added to the ListView, its icon is 1.ico (the first item in the ImageList), rather than 5.ico (the newly added item that should be at the end of the ImageList). Or do I need to re-create the whole ImageList any time the ListView changes? A zip file is attached that contains the script and also the .ico files, for easier testing. Thanks! /John test.zip
-
Hi all, I'm trying to create a listview with subitem icons and I achieved this by simply rearranging the order of the columns, so that the first column is in the middle, thus appearing as a subitem with an icon - this method prevents the "icon clipping" that happens when using subitem icons in a listview. My issue is that when I select a row that does not have an icon, the space where the icon would be is white. Is there a way to make this transparent, so it looks like the entire row is selected? Here's an example - click the second listview item/row to see a blank space where the icon would be. #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> _Main() Func _Main() Local $hGui, $listview, $hImage Local $iLV_EXStyle_NoChecks = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_HEADERDRAGDROP) $hGui = GUICreate("Listview Test With Icons", 400, 300) $listview = GUICtrlCreateListView("Col 1|Col 2|Col 3", 2, 2, 394, 268, BitOR($LVS_REPORT, $LVS_SHAREIMAGELISTS)) _GUICtrlListView_SetExtendedListViewStyle($listview, $iLV_EXStyle_NoChecks) GUISetState() ; Create the image list $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) _GUICtrlListView_SetImageList($listview, $hImage, 1) ; Set the order so the first column is moved to the middle, ; acting like a subitem with an icon _GUICtrlListView_SetColumnOrder($listview, "1|0|2") ; Add the items GUICtrlCreateListViewItem("Item1|Item2|Item3", $listview) GUICtrlCreateListViewItem("Item4|Item5|Item6", $listview) ; Set an icon for just the first item _GUICtrlListView_SetItemImage($listview, 0, 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main
-
Function Reference _GuiImageListEx.au3 Functions that assist with ImageList control management with support a vertical image strip! Sintax: _GUIImageList_AddVerticalStrip( hWnd, hInstance, sImage[, iWidth = 0[, iHeight = 0[, iImgCount = -1 ]]] ) _GUIImageList_DrawVerticalStrip( hWnd, iIndex, hDC, iX, iY[, iStyle = 0 ] ) _GUIImageList_DrawVerticalStripEx( hWnd, iIndex, hDC, iX, iY[, iDX = 0[, iDY = 0[, iStyle = 0 ] ) _GUIImageList_DestroyEx( hWnd ) Supports: ; Bitmaps with vertical image strip! Downloads: Version: 0.12 _GuiImageListEx_(RedirectLink).html Note: Solve this old problem: Need the WinApiEx.au3: Usage example is included! Sample: Fixes: Regards, João Carlos.
- 4 replies
-
- _guiimagelist
- draw
-
(and 5 more)
Tagged with:
-
After reading a topic that supposedly has this fixed/solved - I am trying this - dependancy udf #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Res_File_Add=glasses.png, 10, glasses_png #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> #include "resources.au3" _Main() Func _Main() Local $listview, $hImage Local $Wow64 = "" If @AutoItX64 Then $Wow64 = "\Wow6432Node" Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images" GUICreate("ImageList AddBitmap", 400, 300) $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState() ; Load images $hImage = _GUIImageList_Create(16, 32, 5, 3) _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp") _GUIImageList_AddBitmap($hImage, $sPath & "\Green.bmp") _GUIImageList_AddEx($hImage, "glasses_png") _GUICtrlListView_SetImageList($listview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($listview, "Items", 120) ; Add items _GUICtrlListView_AddItem($listview, "Item 1", 0) _GUICtrlListView_AddItem($listview, "Item 2", 1) _GUICtrlListView_AddItem($listview, "Item 3", 2) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func _GUIImageList_AddEx($hImageList, $sResource) Local $handleimg = _ResourceGet($sResource, $RT_BITMAP) _GUIImageList_Add($hImageList, $handleimg) _WinAPI_DeleteObject($handleimg) Return 1 EndFunc ;==>_GUIImageList_AddEx But no avail, i am thinking am i doing some stupid mistake here but cant seem to find it...