Bam Posted February 8, 2009 Share Posted February 8, 2009 Hello, I got every thing worken pretty good and was about finished with it till i got to the delete last button. I can't get it to delete the last row on the listview, ive had 3 items and had the delete set to any thing from 0 to 3 and wouldnt delete any of them, so was looken for some help heres the code: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> ;#include <StaticConstants.au3> ;#include <WindowsConstants.au3> #include <GuiListView.au3> #include <string.au3> Local $S #Region ### START Koda GUI section ### Form=c:\documents and settings\bam bam\desktop\eta.kxf $Form1 = GUICreate("Bam's ETA", 301, 162, 193, 125) $Label_Distance = GUICtrlCreateLabel("Distance:", 10, 10, 49, 17) $Edit_Distance = GUICtrlCreateEdit("", 70, 10, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Label_Speed = GUICtrlCreateLabel("Speed:", 10, 40, 38, 17) $Edit_Speed = GUICtrlCreateEdit("", 70, 40, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Label_Minutes = GUICtrlCreateLabel("Minutes:", 10, 70, 44, 17) $Edit_Mintues = GUICtrlCreateEdit("", 70, 70, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Label_Seconds = GUICtrlCreateLabel("Seconds:", 10, 100, 49, 17) $Edit_Seconds = GUICtrlCreateEdit("", 70, 100, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Button_ETA = GUICtrlCreateButton("ETA", 30, 130, 71, 21, $BS_DEFPUSHBUTTON) $ListView1 = GUICtrlCreateListView("", 140, 10, 141, 111) $Button_DeleteLast = GUICtrlCreateButton("Delete Last", 160, 130, 71, 21, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_InsertColumn($ListView1, 0, "ETA", 50, 2) _GUICtrlListView_InsertColumn($ListView1, 1, "Total ETA", 75) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_ETA $IndexCount = _GUICtrlListView_GetItemCount($ListView1) $Distance = GUICtrlRead($Edit_Distance) $Speed = GUICtrlRead($Edit_Speed) $Minutes = Floor($Distance / $Speed * 60) GUICtrlSetData($Edit_Mintues, $Minutes) $A = $Distance / $Speed * 60 $Seconds = Floor(($A - Floor($A)) * 60) GUICtrlSetData($Edit_Seconds, $Seconds) _GUICtrlListView_AddItem($ListView1, $Minutes & ":" & $Seconds, 0) $Last_ETA = _GUICtrlListView_GetItem($ListView1, $IndexCount - 1, 1) $S = StringInStr($Last_ETA[3], ":") $Last_ETA_Minutes = StringMid($Last_ETA[3], 1, $S - 1) $Last_ETA_Seconds = StringMid($Last_ETA[3], $S + 1, $S + 3) If $Last_ETA_Seconds + $Seconds > 60 Then $Last_ETA_Seconds -= 60 $Last_ETA_Minutes += 1 EndIf $TotalETA = $Last_ETA_Minutes + $Minutes & ":" & $Last_ETA_Seconds + $Seconds _GUICtrlListView_AddSubItem($ListView1, $IndexCount, $TotalETA, 1) Case $Button_DeleteLast $IndexCount = _GUICtrlListView_GetItemCount($ListView1) ConsoleWrite($IndexCount) _GUICtrlListView_DeleteItem($ListView1, $S-1) EndSwitch WEnd Its for flight plans for pilots so u can find how long the route will take with each leg. Link to comment Share on other sites More sharing options...
Authenticity Posted February 8, 2009 Share Posted February 8, 2009 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <string.au3> Local $S #Region ### START Koda GUI section ### Form=c:\documents and settings\bam bam\desktop\eta.kxf $Form1 = GUICreate("Bam's ETA", 301, 162, 193, 125) $Label_Distance = GUICtrlCreateLabel("Distance:", 10, 10, 49, 17) $Edit_Distance = GUICtrlCreateEdit("", 70, 10, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Label_Speed = GUICtrlCreateLabel("Speed:", 10, 40, 38, 17) $Edit_Speed = GUICtrlCreateEdit("", 70, 40, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Label_Minutes = GUICtrlCreateLabel("Minutes:", 10, 70, 44, 17) $Edit_Mintues = GUICtrlCreateEdit("", 70, 70, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Label_Seconds = GUICtrlCreateLabel("Seconds:", 10, 100, 49, 17) $Edit_Seconds = GUICtrlCreateEdit("", 70, 100, 51, 21, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "") $Button_ETA = GUICtrlCreateButton("ETA", 30, 130, 71, 21, $BS_DEFPUSHBUTTON) $ListView1 = GUICtrlCreateListView("", 140, 10, 141, 111) $Button_DeleteLast = GUICtrlCreateButton("Delete Last", 160, 130, 71, 21, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_InsertColumn($ListView1, 0, "ETA", 50, 2) _GUICtrlListView_InsertColumn($ListView1, 1, "Total ETA", 75) Dim $hListView = GUICtrlGetHandle($ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button_ETA $IndexCount = _GUICtrlListView_GetItemCount($ListView1) $Distance = GUICtrlRead($Edit_Distance) $Speed = GUICtrlRead($Edit_Speed) $Minutes = Floor($Distance / $Speed * 60) GUICtrlSetData($Edit_Mintues, $Minutes) $A = $Distance / $Speed * 60 $Seconds = Floor(($A - Floor($A)) * 60) GUICtrlSetData($Edit_Seconds, $Seconds) _GUICtrlListView_AddItem($ListView1, $Minutes & ":" & $Seconds, 0) $Last_ETA = _GUICtrlListView_GetItem($ListView1, $IndexCount - 1, 1) $S = StringInStr($Last_ETA[3], ":") $Last_ETA_Minutes = StringMid($Last_ETA[3], 1, $S - 1) $Last_ETA_Seconds = StringMid($Last_ETA[3], $S + 1, $S + 3) If $Last_ETA_Seconds + $Seconds > 60 Then $Last_ETA_Seconds -= 60 $Last_ETA_Minutes += 1 EndIf $TotalETA = $Last_ETA_Minutes + $Minutes & ":" & $Last_ETA_Seconds + $Seconds _GUICtrlListView_AddSubItem($ListView1, $IndexCount, $TotalETA, 1) Case $Button_DeleteLast $IndexCount = _GUICtrlListView_GetItemCount($ListView1) ConsoleWrite($IndexCount) _GUICtrlListView_DeleteItem($hListView, $IndexCount-1) EndSwitch WEnd Added Dim $hListView = GuiCtrlGetHandle($ListView1). Also, on line 62 you stored the counter on $IndexCount but used $S-1. Link to comment Share on other sites More sharing options...
Bam Posted February 8, 2009 Author Share Posted February 8, 2009 ahh TY 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