Jump to content
Sign in to follow this  
cheeseandcereal

Switching between forms

Recommended Posts

cheeseandcereal

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)

Share this post


Link to post
Share on other sites
water

You could use

GUISetState($Form2, @SW_HIDE)
to hide a form.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Nessie

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

Share this post


Link to post
Share on other sites
guinness

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
AutoBert

I think he search for GUISetState:

#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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×