Search the Community
Showing results for tags '_GUICtrlListView_AddItem'.
-
Hello guys, I would like to upload images in listview from a folder, but it does not work well, the list view repeat random the jpg!! But if I use _GUICtrlListView_SetImageList($idListview, $hImage, 1) the array work fine because write all images paths, the problem come when I try to see the images, where did i do wrong? THX #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $idListview, $hImage GUICreate("ImageList AddBitmap", 800, 600) $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(64, 64) ; Add columns _GUICtrlListView_AddColumn($idListview, "Image", 64) Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\Nuova cartella", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 _GDIPlus_Startup() For $y = 1 To $fileArray $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image! $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ;Add items _GUICtrlListView_AddItem($idListview, $aArray[$y], $img) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete()
-
First of all, I am starting with GUIs but reading examples from the helpfile as well as the forum I made an script in which I have a listview that is going to be populated with user input and sorted at any given moment. When I sort it by the first or second column with the data that was already set when starting the script (1|D,2|C,4|A,3|D ) It sorts correctly but when I add a new element it doesn't sort it right, it seems it dismisses the new entered data. Here is a small example of my code to show the issue: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form1_1 = GUICreate("Form1", 969, 569, 209, 134) $ListView1 = GUICtrlCreateListView("Col1|Col2", 32, 128, 353, 321, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_RegisterSortCallBack($ListView1) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 115) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 115) $ListView1_0 = GUICtrlCreateListViewItem("1|D", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("2|C", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("4|A", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("3|B", $ListView1) $bElim = GUICtrlCreateButton("Delete element(s)", 176, 464, 201, 25) $elem = GUICtrlCreateInput("Element", 88, 16, 241, 21) $bAdd = GUICtrlCreateButton("Add letter", 112, 48, 201, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($ListView1) Exit Case $ListView1 _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) Case $bElim $i = 0 $cantitems = _GUICtrlListView_GetItemCount(GUICtrlGetHandle($ListView1)) While $i <= $cantitems If _GUICtrlListView_GetItemChecked(GUICtrlGetHandle($ListView1), $i) Then _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView1), $i) Else $i += 1 EndIf WEnd Case $bAdd $number = Random(0, 100, 1) $handlelista = GUICtrlGetHandle($ListView1) _GUICtrlListView_AddItem($handlelista, $number) _GUICtrlListView_AddSubItem($handlelista, _GUICtrlListView_GetItemCount(GUICtrlGetHandle($ListView1)) - 1, GUICtrlRead($elem), 1) EndSwitch WEnd Note that if you delete all the elements that are set after the script started and you add new ones, it doesn't sort them. What's wrong? Thanks for your help!
- 5 replies
-
- _GUICtrlListView_AddItem
- _GUICtrlListView_AddSubItem
- (and 2 more)