Jump to content

Seems to be impossible to add an icon to a ListView Item !


Recommended Posts

I am trying to add a specific icon or image to a specific ListView Item . I add the items in the ListView control with this command : _GUICtrlListView_AddItem .

Right now what I only managed to do is to add an icon for ALL the items in the control, BUT, if I try to add an icon to only one item , its just impossible :( Atleast for me >_<

I have tried GUICtrlSetImage(-1, "C:icon.ico") tried with creating _GUIImageList_Create , icons not transparent , 16x16 pixels, tried many other icons, tried with .bmp, .png - nothing worked so far O_O !

Anyone yet managed to do something with this problem so far? :blink::( Thanks :)

Edited by Rickname
Link to comment
Share on other sites

  • Moderators

How about posting your code, so we can see what you're doing? Otherwise we have to first guess at what you have thus far, and then try to troubleshoot it. ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Nvm, I managed myself :) The problem was that the picture must be either .bmp. either .ico type.

The source code I used :) :

#include <WinAPI.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#Include <WinAPI.au3>
_Main()

Func _Main()

    GUICreate("ImageList AddBitmap", 400, 300)
    $listview = GUICtrlCreateListView("Items", 2, 2, 394, 268)
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create(32,32)
    _GUIImageList_AddBitmap($hImage, "C:\pic.bmp")
    _GUICtrlListView_SetImageList($listview, $hImage, 1)

    ; Add items
    _GUICtrlListView_AddItem($listview, "Item 1", 0)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main
Edited by Rickname
Link to comment
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
 Share

×
×
  • Create New...