JohnBailey Posted September 3, 2007 Share Posted September 3, 2007 Every time I click Menu -> Save Columns in the below script, the ParentWin disappears. Anyone have a clue as to why? expandcollapse popupGlobal $version = '1.0.0' Global $scriptName = StringTrimRight(@ScriptName,4) Global $debug = 0 If $debug = 1 Then HotKeySet("{ESC}", "Terminate") Opt("TrayIconDebug", 1) Opt("WinSearchChildren", 1) Opt ("GUIOnEventMode", 1) Opt("OnExitFunc", "OnAutoItExit") #include <GUIConstants.au3> #include <File.au3> #include <Array.au3> #include <GuiListView.au3> #Include <WinAnimation.au3> #include <jClassPersonalINDEX.au3> Global $ConfirmsHeaders = 'Account|Date|Type|Ticker|Amount|Units|NAV|Account Name|Notes' Global $DivsHeaders = 'Account|Date|Ticker|Amount|Units|Account Name' Global $DepWdsHeaders = 'Account|Date|Deposit|Withdrawal|Account Name|Notes' Global $ConfirmsFile = 'I:\SAI\Prices\All_Confirms.txt' Global $DivsFile = 'I:\SAI\Prices\All_Div.txt' Global $DepWdsFile = 'I:\SAI\Prices\All_WdDeps.txt' Global $LV_Main_headers Global $columnsCount, $dbArray2D, $dbfileArray, $guiOpen, $Selection, $OpenFromParent = 0 Global $columnInfoArray Global $iniFile = @ScriptDir&'\Data Files\Confirms - Viewer.ini' Global $SettingsIR_columnDelimiter = IniRead($iniFile,'column settings','columnInfodelimiter','') _jCheckIRvar($SettingsIR_columnDelimiter) If $CmdLine[0] <> 0 Then If StringInStr($CmdLine[1],'Launched_from_Parent') > 0 Then Global $WinPos_Left = $CmdLine[3] Global $WinPos_Top = $CmdLine[4] Global $SentSelection = $CmdLine[5] _LoadListViewHeaders($SentSelection) $OpenFromParent = 1 ;#NoTrayIcon Else MsgBox(0,'Error',$CmdLine[1]) EndIf Else #Region ### START Koda GUI section ### Form=I:\SAI\Auto-It files\GUI Designs\Confirms - Viewer - startup.kxf $ParentWin = GUICreate("What do you want to view?", 609, 92, 303, 219) $ConfirmsSelectBTN = GUICtrlCreateButton("Confirms", 38, 32, 148, 25, 0) $DivsSelectBTN = GUICtrlCreateButton("Divs", 229, 32, 148, 25, 0) $DepWdsSelectBTN = GUICtrlCreateButton("WithDeposits", 421, 32, 148, 25, 0) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents") GUICtrlSetOnEvent($ConfirmsSelectBTN, "_ButtonsPressed") GUICtrlSetOnEvent($DivsSelectBTN, "_ButtonsPressed") GUICtrlSetOnEvent($DepWdsSelectBTN, "_ButtonsPressed") $guiOpen = 1 While $guiOpen = 1 Sleep(10) WEnd #EndRegion ### END Koda GUI section ### EndIf #Region ### START Koda GUI section ### Form=I:\SAI\Auto-It files\GUI Designs\Confirms - Viewer.kxf If $OpenFromParent = 1 Then $ParentWin = GUICreate("Confirms Viewer - "&$Selection, 924, 510,$WinPos_Left,$WinPos_Top,$WS_SIZEBOX) _WinAnimate($ParentWin, $AW_SLIDE_OUT_Bottom) $ParentWin_Title_Real = StringReplace($CmdLine[2],'_',' ') $WinOpenAnimation = 1 Else $ParentWin = GUICreate("Confirms Viewer - "&$Selection, 924, 510,-1,-1,$WS_SIZEBOX) EndIf $MenuBar = GUICtrlCreateMenu("Menu") $MenuBar_SaveColumns = GUICtrlCreateMenuitem ("Save Columns",$MenuBar) $LV_Main = GUICtrlCreateListView($LV_Main_headers, 9, 8, 905, 444) GUICtrlSetResizing ($LV_Main,$GUI_DOCKAUTO) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents") GUICtrlSetOnEvent($MenuBar_SaveColumns, "_ButtonsPressed") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; _LoadColumnInfo() _LoadListViewElements($LV_Main) While 1 Sleep(20) WEnd Func _LoadListViewElements(ByRef $lvID) For $x = 1 to UBound($dbfileArray)-1 Local $itemLine = '' For $xx = 1 to $columnsCount If $xx = $columnsCount Then $itemLine &= $dbArray2D[$x][$xx-1] Else $itemLine &= $dbArray2D[$x][$xx-1]&'|' EndIf Next GUICtrlCreateListViewItem($itemLine, $lvID) Next ;Use Stored Data For $x = 1 to UBound($columnInfoArray)-1 _GUICtrlListViewSetColumnWidth($lvID,$x-1,Number($columnInfoArray[$x][1])) Next EndFunc Func _LoadColumnInfo() Local $lci_ColumnInfoFile = @ScriptDir&'\Data Files\Confirms - Viewer - ColumnInfo - '&$Selection&'.txt' ; just to get the count === start Local $lci_columnInfoEntriesArray _FileReadToArray($lci_ColumnInfoFile,$lci_columnInfoEntriesArray) Local $lci_columnInfoEntrySplit = StringSplit($lci_columnInfoEntriesArray[1],$SettingsIR_columnDelimiter,1) ; === end Local $lci_ColumnInfoArray_Columns = $lci_columnInfoEntrySplit[0] ;MsgBox(0,'$lci_ColumnInfoArray_Columns',$lci_ColumnInfoArray_Columns) Global $columnInfoArray[UBound($lci_columnInfoEntriesArray)][$lci_ColumnInfoArray_Columns] Local $lci_x = 1 For $lci_x = 1 to UBound($lci_columnInfoEntriesArray)-1 Local $lci_readSplitArray = StringSplit($lci_columnInfoEntriesArray[$lci_x],$SettingsIR_columnDelimiter,1) ;_ArrayDisplay($lci_readSplitArray) ;_ArrayDisplay($lci_columnInfoEntriesArray) Local $lci_xx = 0 For $lci_xx = 1 to Ubound($lci_readSplitArray)-1 $columnInfoArray[$lci_x][$lci_xx-1] = $lci_readSplitArray[$lci_xx] Next Next EndFunc Func _LoadListViewHeaders($llve_Selection) ;Set Column Headers and Array $Selection = $llve_Selection Global $dbfile = Eval($llve_Selection&'File') ;MsgBox(0,'File',$dbfile) Global $dbfileArray _FileReadToArray($dbfile,$dbfileArray) Local $columnsCountGet = StringSplit(Eval($llve_Selection&'Headers'),'|') ;MsgBox(0,'Headers',Eval($llve_Selection&'Headers')) Global $columnsCount = $columnsCountGet[0] Global $dbArray2D[UBound($dbfileArray)][$columnsCount] Local $x $LV_Main_headers=Eval($llve_Selection&'Headers') For $x = 1 to UBound($dbfileArray)-1 Local $readSplit = StringSplit($dbfileArray[$x],',',1) ;Column Info For $xx = 0 to $readSplit[0]-1 $dbArray2D[$x][$xx] = $readSplit[$xx+1];header Next Next EndFunc Func _ButtonsPressed() Switch @GUI_CTRLID Case $ConfirmsSelectBTN _LoadListViewHeaders('Confirms') GUIDelete($ParentWin) $guiOpen = 0 Case $DivsSelectBTN _LoadListViewHeaders('Divs') GUIDelete($ParentWin) $guiOpen = 0 Case $DepWdsSelectBTN _LoadListViewHeaders('DepWds') GUIDelete($ParentWin) $guiOpen = 0 Case $MenuBar_SaveColumns MsgBox(0,'hi','') EndSwitch EndFunc Func _GUIEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc ;==>_GUIEvents Func OnAutoItExit() ConsoleWrite('CLOSED via Exit'&@CRLF) EndFunc Func Terminate() ConsoleWrite('CLOSED via Terminate'&@CRLF) Exit EndFunc A decision is a powerful thing Link to comment Share on other sites More sharing options...
martin Posted September 4, 2007 Share Posted September 4, 2007 Every time I click Menu -> Save Columns in the below script, the ParentWin disappears. Anyone have a clue as to why? expandcollapse popupGlobal $version = '1.0.0' Global $scriptName = StringTrimRight(@ScriptName,4) Global $debug = 0 If $debug = 1 Then HotKeySet("{ESC}", "Terminate") Opt("TrayIconDebug", 1) Opt("WinSearchChildren", 1) Opt ("GUIOnEventMode", 1) Opt("OnExitFunc", "OnAutoItExit") #include <GUIConstants.au3> #include <File.au3> #include <Array.au3> #include <GuiListView.au3> #Include <WinAnimation.au3> #include <jClassPersonalINDEX.au3> Global $ConfirmsHeaders = 'Account|Date|Type|Ticker|Amount|Units|NAV|Account Name|Notes' Global $DivsHeaders = 'Account|Date|Ticker|Amount|Units|Account Name' Global $DepWdsHeaders = 'Account|Date|Deposit|Withdrawal|Account Name|Notes' Global $ConfirmsFile = 'I:\SAI\Prices\All_Confirms.txt' Global $DivsFile = 'I:\SAI\Prices\All_Div.txt' Global $DepWdsFile = 'I:\SAI\Prices\All_WdDeps.txt' Global $LV_Main_headers Global $columnsCount, $dbArray2D, $dbfileArray, $guiOpen, $Selection, $OpenFromParent = 0 Global $columnInfoArray Global $iniFile = @ScriptDir&'\Data Files\Confirms - Viewer.ini' Global $SettingsIR_columnDelimiter = IniRead($iniFile,'column settings','columnInfodelimiter','') _jCheckIRvar($SettingsIR_columnDelimiter) If $CmdLine[0] <> 0 Then If StringInStr($CmdLine[1],'Launched_from_Parent') > 0 Then Global $WinPos_Left = $CmdLine[3] Global $WinPos_Top = $CmdLine[4] Global $SentSelection = $CmdLine[5] _LoadListViewHeaders($SentSelection) $OpenFromParent = 1 ;#NoTrayIcon Else MsgBox(0,'Error',$CmdLine[1]) EndIf Else #Region ### START Koda GUI section ### Form=I:\SAI\Auto-It files\GUI Designs\Confirms - Viewer - startup.kxf $ParentWin = GUICreate("What do you want to view?", 609, 92, 303, 219) $ConfirmsSelectBTN = GUICtrlCreateButton("Confirms", 38, 32, 148, 25, 0) $DivsSelectBTN = GUICtrlCreateButton("Divs", 229, 32, 148, 25, 0) $DepWdsSelectBTN = GUICtrlCreateButton("WithDeposits", 421, 32, 148, 25, 0) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents") GUICtrlSetOnEvent($ConfirmsSelectBTN, "_ButtonsPressed") GUICtrlSetOnEvent($DivsSelectBTN, "_ButtonsPressed") GUICtrlSetOnEvent($DepWdsSelectBTN, "_ButtonsPressed") $guiOpen = 1 While $guiOpen = 1 Sleep(10) WEnd #EndRegion ### END Koda GUI section ### EndIf #Region ### START Koda GUI section ### Form=I:\SAI\Auto-It files\GUI Designs\Confirms - Viewer.kxf If $OpenFromParent = 1 Then $ParentWin = GUICreate("Confirms Viewer - "&$Selection, 924, 510,$WinPos_Left,$WinPos_Top,$WS_SIZEBOX) _WinAnimate($ParentWin, $AW_SLIDE_OUT_Bottom) $ParentWin_Title_Real = StringReplace($CmdLine[2],'_',' ') $WinOpenAnimation = 1 Else $ParentWin = GUICreate("Confirms Viewer - "&$Selection, 924, 510,-1,-1,$WS_SIZEBOX) EndIf $MenuBar = GUICtrlCreateMenu("Menu") $MenuBar_SaveColumns = GUICtrlCreateMenuitem ("Save Columns",$MenuBar) $LV_Main = GUICtrlCreateListView($LV_Main_headers, 9, 8, 905, 444) GUICtrlSetResizing ($LV_Main,$GUI_DOCKAUTO) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvents") GUICtrlSetOnEvent($MenuBar_SaveColumns, "_ButtonsPressed") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; _LoadColumnInfo() _LoadListViewElements($LV_Main) While 1 Sleep(20) WEnd Func _LoadListViewElements(ByRef $lvID) For $x = 1 to UBound($dbfileArray)-1 Local $itemLine = '' For $xx = 1 to $columnsCount If $xx = $columnsCount Then $itemLine &= $dbArray2D[$x][$xx-1] Else $itemLine &= $dbArray2D[$x][$xx-1]&'|' EndIf Next GUICtrlCreateListViewItem($itemLine, $lvID) Next ;Use Stored Data For $x = 1 to UBound($columnInfoArray)-1 _GUICtrlListViewSetColumnWidth($lvID,$x-1,Number($columnInfoArray[$x][1])) Next EndFunc Func _LoadColumnInfo() Local $lci_ColumnInfoFile = @ScriptDir&'\Data Files\Confirms - Viewer - ColumnInfo - '&$Selection&'.txt' ; just to get the count === start Local $lci_columnInfoEntriesArray _FileReadToArray($lci_ColumnInfoFile,$lci_columnInfoEntriesArray) Local $lci_columnInfoEntrySplit = StringSplit($lci_columnInfoEntriesArray[1],$SettingsIR_columnDelimiter,1) ; === end Local $lci_ColumnInfoArray_Columns = $lci_columnInfoEntrySplit[0] ;MsgBox(0,'$lci_ColumnInfoArray_Columns',$lci_ColumnInfoArray_Columns) Global $columnInfoArray[UBound($lci_columnInfoEntriesArray)][$lci_ColumnInfoArray_Columns] Local $lci_x = 1 For $lci_x = 1 to UBound($lci_columnInfoEntriesArray)-1 Local $lci_readSplitArray = StringSplit($lci_columnInfoEntriesArray[$lci_x],$SettingsIR_columnDelimiter,1) ;_ArrayDisplay($lci_readSplitArray) ;_ArrayDisplay($lci_columnInfoEntriesArray) Local $lci_xx = 0 For $lci_xx = 1 to Ubound($lci_readSplitArray)-1 $columnInfoArray[$lci_x][$lci_xx-1] = $lci_readSplitArray[$lci_xx] Next Next EndFunc Func _LoadListViewHeaders($llve_Selection) ;Set Column Headers and Array $Selection = $llve_Selection Global $dbfile = Eval($llve_Selection&'File') ;MsgBox(0,'File',$dbfile) Global $dbfileArray _FileReadToArray($dbfile,$dbfileArray) Local $columnsCountGet = StringSplit(Eval($llve_Selection&'Headers'),'|') ;MsgBox(0,'Headers',Eval($llve_Selection&'Headers')) Global $columnsCount = $columnsCountGet[0] Global $dbArray2D[UBound($dbfileArray)][$columnsCount] Local $x $LV_Main_headers=Eval($llve_Selection&'Headers') For $x = 1 to UBound($dbfileArray)-1 Local $readSplit = StringSplit($dbfileArray[$x],',',1) ;Column Info For $xx = 0 to $readSplit[0]-1 $dbArray2D[$x][$xx] = $readSplit[$xx+1];header Next Next EndFunc Func _ButtonsPressed() Switch @GUI_CTRLID Case $ConfirmsSelectBTN _LoadListViewHeaders('Confirms') GUIDelete($ParentWin) $guiOpen = 0 Case $DivsSelectBTN _LoadListViewHeaders('Divs') GUIDelete($ParentWin) $guiOpen = 0 Case $DepWdsSelectBTN _LoadListViewHeaders('DepWds') GUIDelete($ParentWin) $guiOpen = 0 Case $MenuBar_SaveColumns MsgBox(0,'hi','') EndSwitch EndFunc Func _GUIEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc ;==>_GUIEvents Func OnAutoItExit() ConsoleWrite('CLOSED via Exit'&@CRLF) EndFunc Func Terminate() ConsoleWrite('CLOSED via Terminate'&@CRLF) Exit EndFunc You delete the window but the controls created in it still have id's with values. When you create a new parent window the menu item is given the value of one of the deleted controls. One way is to add to the case statement like this Case $ConfirmsSelectBTN and $guiOpen ;<--- add to each control which is part of the deleted window _LoadListViewHeaders('Confirms') GUIDelete($ParentWin) $guiOpen = 0 etc. The other way is to set the deleted control IDs to zero when you delete the parent window.- $ConfirmsSelectBTN = 0 etc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
JohnBailey Posted September 4, 2007 Author Share Posted September 4, 2007 You delete the window but the controls created in it still have id's with values. When you create a new parent window the menu item is given the value of one of the deleted controls. One way is to add to the case statement like this Case $ConfirmsSelectBTN and $guiOpen ;<--- add to each control which is part of the deleted window _LoadListViewHeaders('Confirms') GUIDelete($ParentWin) $guiOpen = 0etc.The other way is to set the deleted control IDs to zero when you delete the parent window.-$ConfirmsSelectBTN = 0 etcoh cool!!! Thanks Martin!! I didn't even think about them remaining and I wouldn't have thought they would conflict like that. Out of your two options it seems to be a good move to set the IDs to zero, but it might be easier to use the AND method. Is there something I could get in to trouble with later on down the road? I want to work on creating good habits for myself.Thanks again! A decision is a powerful thing 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