danielkza Posted January 28, 2008 Share Posted January 28, 2008 (edited) I'm having trouble creating 2 GUI windows using OnEvent Mode. The first window is created okay,responds normally,but when i create the second one both of them stop responding to commands and the functions never get called. I won't include the main gui code because it's huge and is split between multiple files. Here's the secondary GUI code: expandcollapse popup#include <GUIConstants.au3> #include <Common.au3> Func AddEditSkinDialog($SkinDir,$Edit = 0,$Categorie = -1,$Object = -1,$SkinName = "") Dim $CategorieData Dim $ObjectData Dim $MainForm Global $AddSkin_DialogExitFlag = 0 Global $AddSkin_TempFolder = _TempFile(@TempDir,"~SKIN","") If @error Then MsgBox(16,$WindowTitle,"Error : Unable to create temporary directory in " & @TempDir) Return EndIF DirCreate($AddSkin_TempFolder) #Region ### START Koda GUI section ### Form= Global $AddSkin_Form = GUICreate("Add/Edit Skin", 326, 266, 347, 263,Default,Default,$MainForm) GuiSetOnEvent($GUI_EVENT_CLOSE,"AddSkinDialog_FormClose",$AddSkin_Form) Global $AddSkin_GroupBox = GUICtrlCreateGroup("", 8, 1, 307, 223) Global $AddSkin_NameLabel = GUICtrlCreateLabel("Skin Name", 18, 11, 56, 17) Global $AddSkin_NameInput = GUICtrlCreateInput("", 18, 31, 145, 21) Global $AddSkin_CategorieLabel = GUICtrlCreateLabel("Categorie", 18, 61, 49, 17) Global $AddSkin_CategorieCombo = GUICtrlCreateCombo("", 18, 81, 145, 25) GuiCtrlSetOnEvent($AddSkin_CategorieCombo,"AddSkinDialog_CategorieComboClick") Global $AddSkin_SubCategorieLabel = GUICtrlCreateLabel("Sub-Categorie", 18, 111, 71, 17) Global $AddSkin_SubCategorieCombo = GUICtrlCreateCombo("", 18, 131, 145, 25) Global $AddSkin_AddZipButton = GUICtrlCreateButton("Add Zip", 18, 161, 65, 25, 0) GuiCtrlSetOnEvent($AddSkin_AddZipButton ,"AddSkinDialog_AddZipButtonclick") Global $AddSkin_AddFilesButton = GUICtrlCreateButton("Add Files", 18, 191, 65, 25, 0) GuiCtrlSetOnEvent($AddSkin_AddFilesButton,"AddSkinDialog_AddFilesButtonclick") Global $AddSkin_RemoveButton = GUICtrlCreateButton("Remove", 98, 161, 65, 25, 0) GuiCtrlSetOnEvent($AddSkin_RemoveButton ,"AddSkinDialog_RemoveButtonclick") Global $AddSkin_FileListLabel = GUICtrlCreateLabel("File List", 178, 11, 39, 17) Global $AddSkin_FileList = GUICtrlCreateList("", 178, 31, 131, 188) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $AddSkin_OkButton = GUICtrlCreateButton("&OK", 65, 233, 75, 25, 0) GuiCtrlSetOnEvent($AddSkin_OkButton,"AddSkinDialog_OkButtonclick") Global $AddSkin_CancelButton = GUICtrlCreateButton("&Cancel", 152, 233, 75, 25, 0) GuiCtrlSetOnEvent($AddSkin_CancelButton,"AddSkinDialog_FormClose") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #region Initialize Control Data LoadCategoriesToCombo($AddSkin_CategorieCombo,$CategorieData) If $Edit Then LoadObjectsToCombo($AddSkin_SubCategorieCombo,$ObjectData,$Categorie) If $Categorie > -1 AND $Object > -1 AND $SkinName <> "" Then GuiCtrlSetData($AddSkin_NameInput,$SkinName) _GUICtrlComboBox_SetCurSel(GUICtrlGetHandle($AddSkin_CategorieCombo),$Categorie-1) _GUICtrlComboBox_SetCurSel(GUICtrlGetHandle($AddSkin_SubCategorieCombo),$Object-1) $SearchPath = $SkinDir & "\" $SearchPath &= _FileNameConvertToValid($CategorieData[$Categorie][0]) & "\" $SearchPath &= _FileNameConvertToValid($ObjectData[$Categorie][$Object][0]) & "\" $SearchPath &= $SkinName $Files = RecursiveFileSearch($SearchPath) If NOT @Error Then _GUICtrlListBox_AddFileArray(GuiCtrlGetHandle($AddSkin_FileList),$Files) EndIf EndIf EndIf While 1 Sleep(100) WEnd EndFunc Func AddSkinDialog_OkButtonclick() ; This flag indicates if the dialog finished by the Ok or the Cancel button ; Ok = 1, Cancel = 2 $AddSkin_DialogExitFlag = 1 EndFunc Func AddSkinDialog_FormClose() ; This flag indicates if the dialog finished by the Ok or the Cancel button ; Ok = 1, Cancel = 2 $AddSkin_DialogExitFlag = 2 EndFunc Func AddSkinDialog_CategorieComboClick() Dim $ObjectData Dim $AddSkin_SubCategorieCombo $Pos = _GUiCtrlComboBox_GetCurSel(@GUI_CtrlHandle) If $Pos > -1 Then LoadObjectsToCombo($AddSkin_SubCategorieCombo,$ObjectData,$Pos+1) EndIf EndFunc Func AddSkinDialog_AddZipButtonclick() Dim $AddSkin_FileList $Temp = FileOpenDialog("Add Compressed File","","Compressed Files(*.zip;*.rar)",1) If Not @error Then ;_ZipExtract($Temp,$AddSkin_TempFolder) AddSkinDialog_UpdateFiles() EndIf EndFunc Func AddSkinDialog_RemoveButtonclick() Dim $AddSkin_FileList $Pos = _GUiCtrlListBox_GetCurSel(GUICtrlGetHandle($AddSkin_FileList)) If $Pos > -1 Then _GUICtrlListBox_DeleteString(GuiCtrlGetHandle($AddSkin_FileList),$Pos) EndIf EndFunc Func AddSkinDialog_AddFilesButtonclick() $Temp = FileOpenDialog("Add Files","",Default,4) If Not @error Then $ReturnedFiles = StringSplit($Temp,"|") For $i=1 To $ReturnedFiles[0] FileCopy($ReturnedFiles[$i],$AddSkin_TempFolder,8) Next AddSkinDialog_UpdateFiles() EndIf EndFunc EndFUnc Func AddSkinDialog_UpdateFiles() Dim $AddSkin_TempFolder Dim $AddSkin_FileList Local $Files = RecursiveFileSearch($AddSkin_TempFolder) If NOT @error Then _GUICtrlListBox_AddFileArray(GUICtrlGetHandle($AddSkin_FileList),$Files) Else SetError(1) Return EndIF EndFunc Func _GUICtrlListBox_AddFileArray($hWnd,$Array) _GUICtrlListBox_BeginUpdate($hWnd) _GUICtrlListBox_ResetContent($hWnd) For $i=1 To $Array[0] _GUICtrlListBox_AddString($hWnd,$Array[$i]) Next _GUICtrlListBox_EndUpdate($hWnd) EndFunc Does anybody know what's the problem? Edited January 28, 2008 by danielkza Link to comment Share on other sites More sharing options...
wraithdu Posted January 28, 2008 Share Posted January 28, 2008 This looks like the same problem I had recently. You have to remove the While loop from the function that creates your GUI. It seems you can only have one While loop for GUIs in OnEventMode. Link to comment Share on other sites More sharing options...
danielkza Posted January 28, 2008 Author Share Posted January 28, 2008 This looks like the same problem I had recently. You have to remove the While loop from the function that creates your GUI. It seems you can only have one While loop for GUIs in OnEventMode.Thx,I'll try that. 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