Sign in to follow this  
Followers 0
langthang084

Click on button to create (Active Gui) and delete other gui?

4 posts in this topic

My main Gui has 2 button. Click Button1 to create GUI1, Click Button2 to create GUI 2

How to switch between GUI1 and GUI2 by click Button on the main gui (ex: If im working on GUI1, Click Button2 then GUI2 is actived, and GUI1 is deleted)

Here's my code, but It create too main GUI1 and GUI2

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Global $MainStyle = BitOR($WS_OVERLAPPED, $WS_CAPTION, $WS_SYSMENU, $WS_VISIBLE, $WS_CLIPSIBLINGS, $WS_MINIMIZEBOX)

Global $hMain = GuiCreate("MyGUI", 177, 451, -1, -1, $MainStyle)

Global $Button_1 = GuiCtrlCreateButton("Button1", 20, 20, 130, 40)
Global $Button_2 = GuiCtrlCreateButton("Button2", 20, 90, 130, 40)

GuiSetState(@SW_SHOWNORMAL)

Do
    Switch GuiGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $Button_1
            Global $Gui1 = GuiCreate("MyGUI1", 166, 111, -1, -1, $MainStyle)
            Global $Label_1 = GuiCtrlCreateLabel("GUI 1", 40, 20, 90, 30)

         case $Button_2
            Global $Gui2 = GuiCreate("MyGUI2", 166, 111, -1, -1, $MainStyle)
            Global $Label_1 = GuiCtrlCreateLabel("GUI 2", 40, 20, 90, 30)


            ;
    EndSwitch
Until False
#EndRegion

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I guess you should do a GuiDelete($Gui2) when creating $GUI1 and visa versa.

Other option is to create both GUI's and hide them. Only show them when you need to.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks Jos!

I've resolve this. But how to attach GUI1 on main Gui (when working on GUI1). Because if I click on Main GUI (not the Button), then GUi1 will be hidden

Share this post


Link to post
Share on other sites

Maybe a good place to start reading how to handle multiple GUI's is this WiKI page: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  
Followers 0