eEniquEe Posted December 9, 2010 Posted December 9, 2010 Hi, I am currently working on a project, which involves ListView. And I came across a little problem... I'll be very thankful if someone can help me with it. Well... Here's the problem. I want to have some kind of image in front of the text. So I looked in the Help File, and found this piece of code. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) ;If I change the line above to _GUICtrlListView_AddItem($hListView, "Item 3", -1) it will still show a red square in front of the text 'Item 3', which means that the parameter -1 does not work as expected... ;_GUICtrlListView_AddItem($hListView, "Item 3", -1) ; Get image list handle MsgBox(4160, "Information", "Image List Handle: 0x" & Hex(_GUICtrlListView_GetImageList($hListView, 1))) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Well, I think this is what I need. However, I just want some of the texts to have an image display in front of them, and the rest will have no image. So, I try to change the Image parameter to -1, but still, the image is shown... Have I done something wrong, or is it a bug? Thanks a lot in advance.
KaFu Posted December 9, 2010 Posted December 9, 2010 No bug, but either the Listview contains images or it does not, can't be selected per row. A workaround is to add a color matching the window itself and assign that in case you don't want anything to display. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> #include <Winapi.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, _WinAPI_GetSysColor($COLOR_WINDOW), 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 4) ;If I change the line above to _GUICtrlListView_AddItem($hListView, "Item 3", -1) it will still show a red square in front of the text 'Item 3', which means that the parameter -1 does not work as expected... ;_GUICtrlListView_AddItem($hListView, "Item 3", -1) ; Get image list handle MsgBox(4160, "Information", "Image List Handle: 0x" & Hex(_GUICtrlListView_GetImageList($hListView, 1))) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
kaotkbliss Posted December 9, 2010 Posted December 9, 2010 (edited) _GUICtrlListView_AddItem($hListView, "Item 3", 3) gave me a white square. While I know it's not exactly what you were after, it does make it appear there is no image. *edit* Kafu beat me to the punch Edited December 9, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
eEniquEe Posted December 9, 2010 Author Posted December 9, 2010 Ah, ok, I think I get it. ^^! Thanks you guys sssssooo much for your help. And have a good day,
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now