rasim Posted May 29, 2008 Posted May 29, 2008 Hi! How to create a ListView Item without image (icon)? I want to create the ListView Item without image and ListView subitem with image, but ListView Item be created with zero index of the image list control. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $hGUI = GUICreate("ListView example", 300, 200) $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 10, 10, 280, 150, $LVS_REPORT, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, _ $LVS_EX_SUBITEMIMAGES, $LVS_EX_INFOTIP)) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, "Test item") ;_GUICtrlListView_SetItemImage($hListView, 0, -1) _GUICtrlListView_AddSubItem($hListView, 0, "SubItem test", 1, 1) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd
Zedna Posted May 29, 2008 Posted May 29, 2008 (edited) I used empty icon (none.ico) as the simplest workaround for this in my LogView project.none.ico Edited May 29, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
rasim Posted May 30, 2008 Author Posted May 30, 2008 ZednaHi! Thank you for responce. But this not solved the problem. I can to remove image without a none.ico just used _GUICtrlListView_SetItemImage($hListView, 0, -1), but i don`t like this item left indention.
PartyPooper Posted July 3, 2008 Posted July 3, 2008 I have the same problem. Did you find a solution rasim?
PartyPooper Posted July 3, 2008 Posted July 3, 2008 (edited) The only workaround (very kludgey) I could come up with was to create an initial zero length column and use subitems to display the info: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.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 Create Solid BitMap", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_SUBITEMIMAGES) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($hListView), 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($hListView, "", 0) _GUICtrlListView_AddColumn($hListView, "Col1", 100) _GUICtrlListView_AddColumn($hListView, "Col2", 100) ; Add items For $i = 0 To 2 _GUICtrlListView_AddItem($hListView, ""); add row _GUICtrlListView_AddSubItem($hListView, $i, "item1", 1); add item to col1 with no solid bitmap _GUICtrlListView_AddSubItem($hListView, $i, "item2", 2, $i); add item to col2 with solid colour bitmap Next ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Edit: cleaned up code slightly Edited July 3, 2008 by PartyPooper
GaryFrost Posted July 5, 2008 Posted July 5, 2008 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $hGUI = GUICreate("ListView example", 300, 200) $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 10, 10, 280, 150, $LVS_REPORT, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, _ $LVS_EX_SUBITEMIMAGES, $LVS_EX_INFOTIP)) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, "Test item", _GUIImageList_GetImageCount($hImage) + 1) ;_GUICtrlListView_SetItemImage($hListView, 0, -1) _GUICtrlListView_AddSubItem($hListView, 0, "SubItem test", 1, 1) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
rasim Posted July 6, 2008 Author Posted July 6, 2008 GaryFrostThanks, but as i say above But this not solved the problem. I can to remove image without a none.ico just used _GUICtrlListView_SetItemImage($hListView, 0, -1), but i don`t like this item left indention.
PartyPooper Posted July 6, 2008 Posted July 6, 2008 GaryFrostThanks, but as i say aboveMine doesn't have indents but you are forced to use sub-items.
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