cheeseandcereal Posted March 17, 2013 Share Posted March 17, 2013 So I was wondering what are some good ways for switching between different GUI forms? The way I currently switch between forms is something like this: GUICtrlDelete($Form1) $Form2 = GUICreate("Title", 615, 391, 192, 124) However when I do something like this, the program itself acts like it's closing then opening a new window which doesn't look to elegant, not to mention that if you have moved your window,then do this to switch to a new form, the new window is automatically moved back to it's preset coordinates. Any ideas on how to switch between different forms a little more elegantly? (And I don't want to just switch the order of these commands, because then the window is still moved and the program acts as if it's opening up 2 windows, then closing one of them which doesn't look elegant either) Link to comment Share on other sites More sharing options...
water Posted March 17, 2013 Share Posted March 17, 2013 You could useGUISetState($Form2, @SW_HIDE)to hide a form. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Nessie Posted March 17, 2013 Share Posted March 17, 2013 Have you tried with GUISwitch function? #include <GUIConstantsEx.au3> Example() Func Example() Local $parent1, $parent2, $tabitem, $msg $parent1 = GUICreate("Parent1") GUICtrlCreateTab(10, 10) $tabitem = GUICtrlCreateTabItem("tab1") GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("") $parent2 = GUICreate("Parent2", -1, -1, 100, 100) GUISwitch($parent2) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE GUISwitch($parent1, $tabitem) GUICtrlCreateButton("OK", 50, 50, 50) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW, $parent1) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
guinness Posted March 17, 2013 Share Posted March 17, 2013 Yes, GUISwitch is the little gem. GUISwitch() UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
AutoBert Posted March 18, 2013 Share Posted March 18, 2013 I think he search for GUISetState:expandcollapse popup#include <GUIConstantsEx.au3> #include<WindowsConstants.au3> Global $idGui1, $idGui2=-99, $idMsgBox, $idZurueck, $idbtnExit2 _CreateGui2() ;entweder hier oder erst wenn benötigt ($idbtmToGui2 Klick) $idGui1 = GUICreate('GUI 1', 400, 280, 140, 150, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) $idbtnToGui2 = GUICtrlCreateButton('&Aufruf GUI 2', 20, 20, 130, 25) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) $idbtnICQ = GUICtrlCreateButton('&ICQ', 20, 50, 130, 25) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) $idbtnExit1 = GUICtrlCreateButton('be&enden', 20, 80, 130, 25) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) GUISetState(@SW_SHOW, $idGui1) While 1 $nMsg = GUIGetMsg(1) ;extended Modus wichtig!! Switch $nMsg[1] ;für welches Fenster ist die Message Case $idGui1 ;ab hier ist Gui 1 dran Switch $nMsg[0] ;welche Message wurde ausgelöst Case $idbtnToGui2 GUISetState(@SW_DISABLE , $idGui1) ;Gui 1 disablen, damit nur Gui2 klckbar ist und Gui1 nicht bearbeitet werden kann ;If $idGui2 = -99 Then _CreateGui2() ;nur wenn nicht am Anfang bereits erzeugt nötig, dann auf Vorbelegung der Variable in Global achten) GUISetState(@SW_SHOW , $idGui2) ;Gui 2 anzeigen Case $idbtnICQ MsgBox(0,"ICQ","Jetzt würde ICQ gestartet",0,$idGui1) ;Run("C:\Program Files\ICQ7.0\ICQ.exe") Case $idbtnExit1, $GUI_EVENT_CLOSE _end() EndSwitch Case $idGui2 ;ab hier ist Gui 2 dran Switch $nMsg[0] ;welche Message wurde ausgelöst Case $idMsgBox MsgBox(0, 'Test', 'Test', 0, $idGui2) Case $idZurueck, $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE , $idGui1) ;Gui 1 wieder enablen GUISetState(@SW_HIDE , $idGui2) ;Gui 2 wieder verstecken Case $idbtnExit2 _end() EndSwitch EndSwitch WEnd Func _CreateGui2() $idGui2 = GUICreate('GUI 2', 500, 300, 200, 50, -1, -1, $idGui1) ;wichtig ist der letzte Parameter falls beide gleichzeitig sichtbar sein sollen ;erzeugt eine GUI als Child von Gui1, die zurückgebebene ID wird in der Variablen $idGui2 gespeichert $idMsgBox = GUICtrlCreateButton('&MsgBox', 20, 20, 130, 25) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) $idZurueck = GUICtrlCreateButton('&Zurück zu GUI 1', 20, 50, 130, 25) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) $idbtnExit2 = GUICtrlCreateButton('be&enden', 20, 80, 130, 25) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) EndFunc ;==>_CreateGui2 Func _end() GUIDelete($idGui2) GUIDelete($idGui1) Exit EndFunc ;==>_end 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