Goldy Posted September 19, 2010 Posted September 19, 2010 Hey communiy, 1. my english is not the best but i hope i can declard my problems good enough so you can understand that. I want to know what i have to-do if i close 1 GUI so not all GUIS are closed. Also if i close Form2 only Form2 closed and not the full programm. I hope anyone can understand what i mean :0 Greetz Goldy
ALTIN Posted September 19, 2010 Posted September 19, 2010 (edited) Goldy welcome this great community,I think you have to put the code of every form, in its own function Func form1() ...code for the Form1 EndFunc Func form2() ...code for the Form2 EndFuncand then just use GUICtrlSetState($form2, @SW_HIDE) or GUICtrlSetState($form2, @SW_SHOW)see this example and modify it as per your needs:expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Opt('MustDeclareVars', 0) Opt("GUICloseOnESC", 1) ;1=ESC closes window when ESC is pressed ;main window global variables Global $btnOpen, $msgMain, $mainWindow, $mainWidth = 460, $mainHeight = 350 ;main window width & height Global $childOpen ;Group Pro Version ;child window global positioning variables Global $childWidth = 300 ;reg window width Global $childHeight = 150 ;reg window height Global $childLeft = ($mainWidth - $childWidth)/2 ;child left position from main window Global $childTop = ($mainHeight - $childHeight)/2 ;child top position from main window MainGui() Func MainGui() $mainWindow = GUICreate("Main Window", $mainWidth, $mainHeight) ; will create a dialog box that when displayed is centered GUISetBkColor(0xE0FFFF) ; will change background color $btnOpen = GuiCtrlCreateButton("OPEN second window", 170,150, 125, 25) GUISetState(@SW_SHOW) ; Run the GUI until the window is closed While 1 $msgMain = GUIGetMsg() Select Case $msgMain = $GUI_EVENT_CLOSE ExitLoop Case $msgMain = $btnOpen About_Window() EndSelect WEnd GUIDelete() Exit EndFunc ;==>MainGui Func About_Window() Local $pos = WinGetPos("Main Window") ;get position of main window Local $x = $pos[0] + $childLeft ;set child x position Local $y = $pos[1] + $childTop ;set child y position Global $childWindow = GUICreate("Child Window", $childWidth, $childHeight, $x, $y, $GUI_SS_DEFAULT_GUI, '', $mainWindow) GUISetBkColor(0xE0FFbb) ; will change background color Global $cmdCancel = GUICtrlCreateButton("&Cancel" , 125, 115, 80, 25) GUISetState(@SW_DISABLE, $childWindow) GUISetState(@SW_SHOW, $childWindow) _GUICtrlButton_Enable($cmdCancel, True) GUISetState(@SW_ENABLE, $childWindow) While 1 $msgChild = GuiGetMsg($childWindow) Select Case $msgChild = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $childWindow) ExitLoop Case $msgChild = $cmdCancel GUISetState(@SW_HIDE, $childWindow) ExitLoop EndSelect WEnd EndFunc ;==>Child window :) Edited September 19, 2010 by ALTIN
Goldy Posted September 20, 2010 Author Posted September 20, 2010 Hey, Thanks for your help. I know this sounds a bit like beginner but can you add that to my code when I enter I am not so clear. If you make this for me Big Thx 2 U Here my GUIS : $Form2 = GUICreate("Multi-Game-Quest-Viewer by TheDarkCoderZ // Choose your language", 524, 252, 601, 124) $GER_FLAG = GUICtrlCreatePic("images\deutsche_flagge.jpg", 16, 96, 233, 137) $AMI_ENG_FLAG = GUICtrlCreatePic("images\gbus.gif", 272, 96, 233, 137) $Pic3 = GUICtrlCreatePic("images\german w.jpg", 16, 8, 233, 89) $Pic4 = GUICtrlCreatePic("images\english w.jpg", 272, 8, 233, 89) GUISetState(@SW_SHOW) If @YEAR = 2010 And @MON = 9 And @MDAY = 21 Then MsgBox(0, "", "Frist abgelaufen") Exit EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GER_FLAG, $Pic3 _german() Case $AMI_ENG_FLAG, $Pic4 _english() EndSwitch WEnd expandcollapse popupFunc _german() $Form3 = GUICreate("Multi-Game-Quest-Viewer by TheDarkCoderZ", 384, 246, 191, 409) $KalOnline = GUICtrlCreateButton("KalOnline", 24, 80, 153, 33) $Button3 = GUICtrlCreateButton("Demnächst!", 208, 80, 153, 33) $Button2 = GUICtrlCreateButton("Demnächst!", 208, 136, 153, 33) $Button4 = GUICtrlCreateButton("Demnächst!", 24, 136, 153, 33) $Button5 = GUICtrlCreateButton("Credits", 24, 192, 153, 33) $Beenden = GUICtrlCreateButton("Beenden", 208, 192, 153, 33) $Pic2 = GUICtrlCreatePic("images\logo w.jpg", 24, 8, 337, 73) GUISetState(@SW_SHOW) While 2 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE Exit Case $Beenden Exit Case $Button5 _credits() Case $KalOnline _GerKalOnlineQuest() EndSwitch WEnd EndFunc ;==>_german Func _english() $Form1 = GUICreate("Multi-Game-Quest-Viewer by TheDarkCoderZ", 387, 242, 192, 124) $Button1 = GUICtrlCreateButton("KalOnline", 24, 80, 153, 33) $Button3 = GUICtrlCreateButton("Cooming soon!", 208, 80, 153, 33) $Button2 = GUICtrlCreateButton("Cooming soon!", 208, 136, 153, 33) $Button4 = GUICtrlCreateButton("Cooming soon!", 24, 136, 153, 33) $Button5 = GUICtrlCreateButton("Credits", 24, 192, 153, 33) $Exit = GUICtrlCreateButton("Exit", 208, 192, 153, 33) _bild1() GUISetState(@SW_SHOW) While 3 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Exit Exit Case $Button5 _credits() EndSwitch WEnd EndFunc ;==>_bild1 Func _credits() $Form4 = GUICreate("Multi-Game-Quest-Viewer by TheDarkCoderZ // Credits", 484, 236, 297, 547) $Pic1 = GUICtrlCreatePic("images\credits.jpg", 0, 0, 481, 233) GUISetState(@SW_SHOW) While 4 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_credits Func _GerKalOnlineQuest() $Form5 = GUICreate("Multi-Game-Quest-Viewer by TheDarkCoderZ // KalOnline (German) Quests", 792, 551, 219, 166) $Button1 = GUICtrlCreateButton("Quest 1", 8, 144, 91, 33) $Checkbox1 = GUICtrlCreateCheckbox("", 104, 144, 33, 33) $Button2 = GUICtrlCreateButton("Quest 2", 8, 184, 91, 33) $Checkbox2 = GUICtrlCreateCheckbox("", 104, 192, 17, 17) $Button3 = GUICtrlCreateButton("Quest 3", 8, 224, 91, 33) $Checkbox3 = GUICtrlCreateCheckbox("", 104, 232, 17, 17) $Button4 = GUICtrlCreateButton("Quest 4", 8, 304, 91, 33) $Checkbox4 = GUICtrlCreateCheckbox("", 104, 272, 17, 17) $Button5 = GUICtrlCreateButton("Quest 5", 8, 264, 91, 33) $Checkbox5 = GUICtrlCreateCheckbox("", 104, 312, 17, 17) $Button6 = GUICtrlCreateButton("Quest 6", 8, 344, 91, 33) $Checkbox6 = GUICtrlCreateCheckbox("", 104, 352, 17, 17) $Button7 = GUICtrlCreateButton("Quest 7", 8, 384, 91, 33) $Checkbox7 = GUICtrlCreateCheckbox("", 104, 392, 17, 17) $Button8 = GUICtrlCreateButton("Quest 8", 8, 424, 91, 33) $Checkbox8 = GUICtrlCreateCheckbox("", 105, 432, 15, 17) $Button9 = GUICtrlCreateButton("Quest 9", 8, 464, 91, 33) $Checkbox9 = GUICtrlCreateCheckbox("", 104, 472, 33, 17) $Button10 = GUICtrlCreateButton("Quest 10", 8, 504, 91, 33) $Checkbox10 = GUICtrlCreateCheckbox("", 104, 512, 17, 17) $Button11 = GUICtrlCreateButton("Quest 11", 136, 144, 91, 33) $Checkbox11 = GUICtrlCreateCheckbox("", 232, 152, 17, 17) $Button12 = GUICtrlCreateButton("Quest 12", 136, 184, 91, 33) $Checkbox12 = GUICtrlCreateCheckbox("", 232, 192, 17, 17) $Button13 = GUICtrlCreateButton("Quest 13", 136, 224, 91, 33) $Checkbox13 = GUICtrlCreateCheckbox("", 232, 232, 17, 17) $Button14 = GUICtrlCreateButton("Quest 14", 136, 264, 91, 33) $Checkbox14 = GUICtrlCreateCheckbox("", 232, 272, 17, 17) $Button15 = GUICtrlCreateButton("Quest 15", 136, 304, 91, 33) $Checkbox15 = GUICtrlCreateCheckbox("", 232, 312, 17, 17) $Button16 = GUICtrlCreateButton("Quest 16", 136, 344, 91, 33) $Checkbox16 = GUICtrlCreateCheckbox("", 232, 352, 17, 17) $Button17 = GUICtrlCreateButton("Quest 17", 136, 384, 91, 33) $Checkbox17 = GUICtrlCreateCheckbox("", 232, 392, 17, 17) $Button18 = GUICtrlCreateButton("Quest 18", 136, 424, 91, 33) $Checkbox18 = GUICtrlCreateCheckbox("", 232, 432, 17, 17) $Button19 = GUICtrlCreateButton("Quest 19", 136, 464, 91, 33) $Checkbox19 = GUICtrlCreateCheckbox("", 232, 472, 17, 17) $Button20 = GUICtrlCreateButton("Quest 20", 136, 504, 91, 33) $Checkbox20 = GUICtrlCreateCheckbox("", 232, 512, 17, 17) $Button21 = GUICtrlCreateButton("Quest 21", 264, 144, 91, 33) $Checkbox21 = GUICtrlCreateCheckbox("", 360, 152, 17, 17) $Button22 = GUICtrlCreateButton("Quest 22", 264, 184, 91, 33) $Checkbox22 = GUICtrlCreateCheckbox("", 360, 192, 17, 17) $Button23 = GUICtrlCreateButton("Quest 23", 264, 224, 91, 33) $Checkbox23 = GUICtrlCreateCheckbox("", 360, 232, 17, 17) $Button24 = GUICtrlCreateButton("Quest 24", 264, 264, 91, 33) $Checkbox24 = GUICtrlCreateCheckbox("", 360, 272, 17, 17) $Button25 = GUICtrlCreateButton("Quest 25", 264, 304, 91, 33) $Checkbox25 = GUICtrlCreateCheckbox("", 360, 312, 17, 17) $Pic1 = GUICtrlCreatePic("images\kalquestgerman.jpg", 32, 8, 713, 121) $Button26 = GUICtrlCreateButton("Quest 26", 264, 344, 91, 33) $Checkbox26 = GUICtrlCreateCheckbox("", 360, 352, 17, 17) $Button27 = GUICtrlCreateButton("Quest 27", 264, 384, 91, 33) $Checkbox27 = GUICtrlCreateCheckbox("", 360, 392, 17, 17) $Button28 = GUICtrlCreateButton("Quest 28", 264, 424, 91, 33) $Checkbox28 = GUICtrlCreateCheckbox("", 360, 432, 17, 17) $Button29 = GUICtrlCreateButton("Quest 29", 264, 464, 91, 33) $Checkbox29 = GUICtrlCreateCheckbox("", 360, 472, 17, 17) $Button30 = GUICtrlCreateButton("Quest 30", 264, 504, 91, 33) $Checkbox30 = GUICtrlCreateCheckbox("", 360, 512, 17, 17) $Button31 = GUICtrlCreateButton("Quest 31", 392, 144, 91, 33) $Checkbox31 = GUICtrlCreateCheckbox("", 488, 152, 17, 17) $Button32 = GUICtrlCreateButton("Quest 32", 392, 184, 91, 33) $Checkbox32 = GUICtrlCreateCheckbox("", 488, 192, 17, 17) $Button33 = GUICtrlCreateButton("Quest 33", 392, 224, 91, 33) $Checkbox33 = GUICtrlCreateCheckbox("", 488, 232, 17, 17) $Button34 = GUICtrlCreateButton("Quest 34", 392, 264, 91, 33) $Checkbox34 = GUICtrlCreateCheckbox("", 488, 272, 17, 17) $Button35 = GUICtrlCreateButton("Quest 35", 392, 304, 91, 33) $Checkbox35 = GUICtrlCreateCheckbox("", 488, 312, 17, 17) $Button36 = GUICtrlCreateButton("Quest 36", 392, 344, 91, 33) $Checkbox36 = GUICtrlCreateCheckbox("", 488, 352, 17, 17) $Button37 = GUICtrlCreateButton("Quest 37", 392, 384, 91, 33) $Checkbox37 = GUICtrlCreateCheckbox("", 488, 392, 17, 17) $Button38 = GUICtrlCreateButton("Quest 38", 392, 424, 91, 33) $Checkbox38 = GUICtrlCreateCheckbox("", 488, 432, 17, 17) $Button39 = GUICtrlCreateButton("Quest 39", 392, 464, 91, 33) $Checkbox39 = GUICtrlCreateCheckbox("", 488, 472, 17, 17) $Button40 = GUICtrlCreateButton("Quest 40", 392, 504, 91, 33) $Checkbox40 = GUICtrlCreateCheckbox("", 488, 512, 17, 17) $Button41 = GUICtrlCreateButton("Quest 41", 520, 144, 91, 33) $Checkbox41 = GUICtrlCreateCheckbox("", 616, 152, 17, 17) $Button42 = GUICtrlCreateButton("Quest 42", 520, 184, 91, 33) $Checkbox42 = GUICtrlCreateCheckbox("", 616, 192, 17, 17) $Button43 = GUICtrlCreateButton("Quest 43", 520, 224, 91, 33) $Checkbox43 = GUICtrlCreateCheckbox("", 616, 232, 17, 17) $Button44 = GUICtrlCreateButton("Quest 44", 520, 264, 91, 33) $Checkbox44 = GUICtrlCreateCheckbox("", 616, 272, 17, 17) $Button45 = GUICtrlCreateButton("Quest 45", 520, 304, 91, 33) $Checkbox45 = GUICtrlCreateCheckbox("", 616, 312, 17, 17) $Button46 = GUICtrlCreateButton("Quest 46", 520, 344, 91, 33) $Checkbox46 = GUICtrlCreateCheckbox("", 616, 352, 17, 17) $Button47 = GUICtrlCreateButton("Quest 47", 520, 384, 91, 33) $Checkbox47 = GUICtrlCreateCheckbox("", 616, 392, 17, 17) $Button48 = GUICtrlCreateButton("Quest 48", 520, 424, 91, 33) $Checkbox48 = GUICtrlCreateCheckbox("", 616, 432, 17, 17) $Button49 = GUICtrlCreateButton("Quest 49", 520, 464, 91, 33) $Checkbox49 = GUICtrlCreateCheckbox("", 616, 472, 17, 17) $Button50 = GUICtrlCreateButton("Quest 50", 520, 504, 91, 33) $Checkbox50 = GUICtrlCreateCheckbox("", 616, 512, 17, 17) $Button51 = GUICtrlCreateButton("Quest 51", 648, 144, 91, 33) $Checkbox51 = GUICtrlCreateCheckbox("", 744, 152, 17, 17) $Button52 = GUICtrlCreateButton("Quest 52", 648, 184, 91, 33) $Checkbox52 = GUICtrlCreateCheckbox("", 744, 192, 17, 17) $Button53 = GUICtrlCreateButton("Quest 53", 648, 224, 91, 33) $Checkbox53 = GUICtrlCreateCheckbox("", 744, 232, 17, 17) $Button54 = GUICtrlCreateButton("Quest 54", 648, 264, 91, 33) $Checkbox54 = GUICtrlCreateCheckbox("", 744, 272, 17, 17) $Button55 = GUICtrlCreateButton("Quest 55", 648, 304, 91, 33) $Checkbox55 = GUICtrlCreateCheckbox("", 744, 312, 17, 17) $Button56 = GUICtrlCreateButton("Quest 56", 648, 344, 91, 33) $Checkbox56 = GUICtrlCreateCheckbox("", 744, 352, 17, 17) $Button57 = GUICtrlCreateButton("Quest 57", 648, 384, 91, 33) $Checkbox57 = GUICtrlCreateCheckbox("", 744, 392, 17, 17) $Button58 = GUICtrlCreateButton("Quest 58", 648, 424, 91, 33) $Checkbox58 = GUICtrlCreateCheckbox("", 744, 432, 17, 17) $Button59 = GUICtrlCreateButton("Quest 59", 648, 464, 91, 33) $Checkbox59 = GUICtrlCreateCheckbox("", 744, 472, 17, 17) $Button60 = GUICtrlCreateButton("Quest 60", 648, 504, 91, 33) $Checkbox60 = GUICtrlCreateCheckbox("", 744, 512, 17, 17) GUISetState(@SW_SHOW) While 5 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_GerKalOnlineQuest Greetz Goldy
ALTIN Posted September 20, 2010 Posted September 20, 2010 (edited) Goldy,you dont have to hard code all control titles in different languages and create many forms. It would be a lose of time and very complicated...The best way is to use IniWrite() and IniRead() functions to write a language file then read from it based in which language is selected by user.I cant do your coding right now because it is 4:00 AM here but take a look at this very basic and clear example in how you should implement it. You basically need 2 forms and you can add as many languages as you want through lang file:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $langSection, $langFile $langFile = "\myLangFile.ini" ;write a language file in %Temp% directory if it does not exist If NOT FileExists(@tempdir & $langFile) Then ;English section IniWrite(@tempdir & $langFile, "english", "title", "English") IniWrite(@tempdir & $langFile, "english", "text1", "Hello english people") IniWrite(@tempdir & $langFile, "english", "text2", "How are you?") IniWrite(@tempdir & $langFile, "english", "text3", "Have a nice day") ;German section IniWrite(@tempdir & $langFile, "german" , "title", "German") IniWrite(@tempdir & $langFile, "german" , "text1", "Hallo leute Deutsch") IniWrite(@tempdir & $langFile, "german" , "text2", "Wie geht es ihnen?") IniWrite(@tempdir & $langFile, "german" , "text3", "Haben einen schonen tag") EndIf SelectLang() Func SelectLang() Local $msg GUICreate("Select Language", 400, 200) $btnEng = GUICtrlCreatebutton("English", 70, 80, 100, 50) $btnGer = GUICtrlCreatebutton("German", 220, 80, 100, 50) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $btnEng $langSection = "english" Form2() Case $btnGer $langSection = "german" Form2() EndSwitch WEnd EndFunc Func Form2() Local $m $tit = IniRead(@tempdir & $langFile, $langSection, "title", "NotFound") $txt1 = IniRead(@tempdir & $langFile, $langSection, "text1", "NotFound") $txt2 = IniRead(@tempdir & $langFile, $langSection, "text2", "NotFound") $txt3 = IniRead(@tempdir & $langFile, $langSection, "text3", "NotFound") GUICreate($tit, 200, 100) GUICtrlCreateLabel($txt1, 20, 20, 150, 20) GUICtrlCreateLabel($txt2, 20, 50, 150, 20) GUICtrlCreateLabel($txt3, 20, 80, 150, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFuncLet me know if you still have difficulties to implement it. I will check tomorrow... good night Edited September 20, 2010 by ALTIN
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