Loc Posted September 23, 2020 Share Posted September 23, 2020 Func Save() FileDelete(@ScriptDir&'\Test.txt') $list_count = _GUICtrlListView_GetItemCount ($ListView1) For $i=0 To $list_count-1 _GUICtrlListView_SetItemSelected($ListView1,$i) $Read = _GUICtrlListView_GetItemTextArray($ListView1) FileWriteLine(@ScriptDir&'\Test.txt',$Read[1]&'|'&$Read[2]&'|'&$Read[3]&'|'&$Read[4]) Next EndFunc Since my source code is so long, I cut it out for everyone to see. Has anyone ever made this mistake? Give me a fix because I use WM_NOTIFY to click on each item so it flashes very Link to comment Share on other sites More sharing options...
Loc Posted September 24, 2020 Author Share Posted September 24, 2020 Looks like no one has encountered this problem right @@ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2020 Moderators Share Posted September 24, 2020 Loc, No-one has replied because it is likely that no-one understands just what the problem actually is - that is certainly true in my case. Posting just a small snippet of your script does not really help at all - you need to post a short runnable script which shows the problem so that we can firstly see what is happening and then offer possible solutions. 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...
Loc Posted September 24, 2020 Author Share Posted September 24, 2020 I save the listview item this way, but when I increase the value, it jumps to the last line. What I need here is when I save an item on a listview that it doesn't jump like that? What I don't know if it's expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form1 = GUICreate("Form1", 615, 437, 359, 123) $ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4", 16, 8, 577, 401) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100) $hListView = GUICtrlGetHandle($ListView) $ListView1_0 = GUICtrlCreateListViewItem("1|2|3|4", $ListView) $ListView1_1 = GUICtrlCreateListViewItem("5|6|7|8", $ListView) $ListView1_2 = GUICtrlCreateListViewItem("9|10|11|12", $ListView) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $nMsg, $wParam, $lParam) Local $stNmhdr = DllStructCreate("dword;int;int", $lParam), $hWndFrom = DllStructGetData($stNmhdr, 1) Local $nNotifyCode = DllStructGetData($stNmhdr, 3) Local $hWndListView = $hListView Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK _SaveLoad() EndSwitch EndSwitch EndFunc Func _SaveLoad() Local $vitrichon , $Value , $newsl , $settext $vitrichon = _GUICtrlListView_GetSelectedColumn($ListView) $settext = _GUICtrlListView_GetSelectedIndices($ListView) $Value = _GUICtrlListView_GetItemTextArray($ListView,$vitrichon) If $Value[1] <> '' Then $newsl = $Value[1] + 1 $newmoney = _TrueValue($Value[2],$newsl) _GUICtrlListView_SetItemText($ListView, $settext,$newsl,0) _GUICtrlListView_SetItemText($ListView, $settext, $newmoney,2) EndIf _Save() EndFunc Func _Save() Local $filename = @ScriptDir & '\Test.txt' Local $hF = FileOpen($filename, 2) $list_count = _GUICtrlListView_GetItemCount ($ListView) For $i=0 To $list_count-1 _GUICtrlListView_SetItemSelected($ListView,$i) $Read = _GUICtrlListView_GetItemTextArray($ListView) FileWriteLine($hF,$Read[1]&'|'&$Read[2]&'|'&$Read[3]&'|'&$Read[4]) Next FileClose($hF) EndFunc Func _TrueValue($money, $sl = '0') Local $xldl, $kq If $sl = '0' Then $kq = StringReplace($money, ',', '') Else $xldl = StringReplace($money, ',', '') $kq = $xldl * $sl EndIf Return $kq EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2020 Moderators Share Posted September 24, 2020 Loc, Do not select each line as you save it: Func _Save() Local $filename = @ScriptDir & '\Test.txt' Local $hF = FileOpen($filename, 2) $list_count = _GUICtrlListView_GetItemCount($ListView) For $i = 0 To $list_count - 1 ;_GUICtrlListView_SetItemSelected($ListView,$i) ; No need to select line <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Read = _GUICtrlListView_GetItemTextArray($ListView, $i) ; Just use the line parameter <<<<<<<<<<<<<<<<< FileWriteLine($hF, $Read[1] & '|' & $Read[2] & '|' & $Read[3] & '|' & $Read[4]) Next FileClose($hF) EndFunc ;==>_Save 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...
Loc Posted September 24, 2020 Author Share Posted September 24, 2020 I tried not to select each line but when saving to txt file it saved all the same items. You can open txt file to see if it looks like me Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2020 Moderators Share Posted September 24, 2020 Loc, Every time I double click a line the file saved mirrors the altered ListView content - here is a modified script which displays the content of the file each time it is written: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $fSaved = False Global $filename = @ScriptDir & '\Test.txt' $Form1 = GUICreate("Form1", 615, 437, 359, 123) $ListView = GUICtrlCreateListView("Column1|Column2|Column3|Column4", 16, 8, 577, 401) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100) $hListView = GUICtrlGetHandle($ListView) $ListView1_0 = GUICtrlCreateListViewItem("1|2|3|4", $ListView) $ListView1_1 = GUICtrlCreateListViewItem("5|6|7|8", $ListView) $ListView1_2 = GUICtrlCreateListViewItem("9|10|11|12", $ListView) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $fSaved Then $aContent = FileReadToArray($filename) _ArrayDisplay($aContent, "", Default, 8) $fSaved = False EndIf WEnd Func WM_NOTIFY($hWnd, $nMsg, $wParam, $lParam) Local $stNmhdr = DllStructCreate("dword;int;int", $lParam), $hWndFrom = DllStructGetData($stNmhdr, 1) Local $nNotifyCode = DllStructGetData($stNmhdr, 3) Local $hWndListView = $hListView Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK _SaveLoad() $fSaved = True EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY Func _SaveLoad() Local $vitrichon, $Value, $newsl, $settext $vitrichon = _GUICtrlListView_GetSelectedColumn($ListView) $settext = _GUICtrlListView_GetSelectedIndices($ListView) $Value = _GUICtrlListView_GetItemTextArray($ListView, $vitrichon) If $Value[1] <> '' Then $newsl = $Value[1] + 1 $newmoney = _TrueValue($Value[2], $newsl) _GUICtrlListView_SetItemText($ListView, $settext, $newsl, 0) _GUICtrlListView_SetItemText($ListView, $settext, $newmoney, 2) EndIf _Save() EndFunc ;==>_SaveLoad Func _Save() Local $hF = FileOpen($filename, 2) $list_count = _GUICtrlListView_GetItemCount($ListView) For $i = 0 To $list_count - 1 ;_GUICtrlListView_SetItemSelected($ListView,$i) $Read = _GUICtrlListView_GetItemTextArray($ListView, $i) FileWriteLine($hF, $Read[1] & '|' & $Read[2] & '|' & $Read[3] & '|' & $Read[4]) Next FileClose($hF) EndFunc ;==>_Save Func _TrueValue($money, $sl = '0') Local $xldl, $kq If $sl = '0' Then $kq = StringReplace($money, ',', '') Else $xldl = StringReplace($money, ',', '') $kq = $xldl * $sl EndIf Return $kq EndFunc ;==>_TrueValue For me the file always matches the ListView content. 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...
Loc Posted September 24, 2020 Author Share Posted September 24, 2020 Yes. Thanks Currently my side is late, tomorrow I will try something I will report back, hoping to still help 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