AlienStar Posted December 25, 2020 Share Posted December 25, 2020 (edited) hello everybody tell me why I can't read listview items please here is my code expandcollapse popup#include <GUIConstants.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GDIPlus.au3> #include <File.au3> Opt("MustDeclareVars", 1) Global $hListView Local $edtpst_db = "C:\Users\User\AppData\Local\PTMW\edtpst_db.ini" Local $hGUI5 = GUICreate("", 650, 550) Local $idListView = GUICtrlCreateListView("", 5, 5, 640, 500, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) Local $hCMenu_edtpst = GUICtrlCreateContextMenu($idListView) Local $edtpst_edt = GUICtrlCreateMenuItem("edit post", $hCMenu_edtpst, 1) ;============================================================================= _GUICtrlListView_SetExtendedListViewStyle($idListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_AddColumn($idListView, "image", 130) ; Must not be too small _GUICtrlListView_AddColumn($idListView, "title", 265) _GUICtrlListView_AddColumn($idListView, "category", 120) _GUICtrlListView_AddColumn($idListView, "date", 100) Local $hListView = GUICtrlGetHandle($idListView) Local $hImage = _GUIImageList_Create(128, 85, 5, 3) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GDIPlus_Startup() Local $aArray = _FileListToArrayRec(@ScriptDir&"\imgtest", "*.jpg", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) Local $iArray = UBound($aArray) - 1, $GDIpBmpLarge, $GDIpBmpResized, $GDIbmp, $img ;_ArrayDisplay($aArray) For $i = 1 To UBound($aArray)-1 $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$i]))) ;GDI+ image! $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 128, 128) ;GDI+ image $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_AddItem($idListView, "", $img) ;---------------------------------------------------------------- _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) ;---------------------------------------------------------------- _GUICtrlListView_AddSubItem($idListView, $i - 1, "Title", 1) ;GUICtrlSetFont(-1, 9, 0, 0, $font) ;---------------------------------------------------------------- _GUICtrlListView_AddSubItem($idListView, $i - 1, "Category", 2) ;GUICtrlSetFont(-1, 9, 0, 0, $font) ;---------------------------------------------------------------- _GUICtrlListView_AddSubItem($idListView, $i - 1, "Date", 3) ;GUICtrlSetFont(-1, 9, 0, 0, $font) ;---------------------------------------------------------------- Next _GDIPlus_Shutdown() GUISetState(@SW_SHOW) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $edtpst_edt Local $idListView_rd = GUICtrlRead(GUICtrlRead($idListView)) MsgBox(0,"",$idListView_rd) EndSwitch WEnd ; Cleanup GUIDelete() Edited December 25, 2020 by AlienStar Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 25, 2020 Moderators Share Posted December 25, 2020 AlienStar, I imagine it is because you have added items using the _GUICtrlListView UDF functions and not the native GUICtrlCreateListViewItem function. Thus there is no ControlID for GUICtrlRead to use. Try using the native function to add the elements to your ListView and you should be able to read them. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AlienStar Posted December 25, 2020 Author Share Posted December 25, 2020 (edited) 25 minutes ago, Melba23 said: AlienStar, I imagine it is because you have added items using the _GUICtrlListView UDF functions and not the native GUICtrlCreateListViewItem function. Thus there is no ControlID for GUICtrlRead to use. Try using the native function to add the elements to your ListView and you should be able to read them. M23 I am compelled to do so, because I need to add images in listview. would you tell me how to solve please ? Edited December 25, 2020 by AlienStar Link to comment Share on other sites More sharing options...
Subz Posted December 25, 2020 Share Posted December 25, 2020 You can use the _GuiCtrlListView functions for example: Local $idListView_rd = _GUICtrlListView_GetItemTextString ($idListView, Number(_GUICtrlListView_GetSelectedIndices($idListView))) AlienStar 1 Link to comment Share on other sites More sharing options...
AlienStar Posted December 26, 2020 Author Share Posted December 26, 2020 10 hours ago, Subz said: You can use the _GuiCtrlListView functions for example: Local $idListView_rd = _GUICtrlListView_GetItemTextString ($idListView, Number(_GUICtrlListView_GetSelectedIndices($idListView))) you are amazing thanks so much Link to comment Share on other sites More sharing options...
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