Jump to content
Sign in to follow this  
niubbone

Making 2 or more guis

Recommended Posts

niubbone

It seems ridiculous, but I haven't found any helpful guide, thread, FAQ, Help File, Google in English and in my mother tongue to make a multiple gui program with GuiGetMsg() code, but it seems I'm not able to find anything good for me.

All the examples i found, bring to OnEvent multiple guis. I would like to have a GUI with buttons, and when I click for example button 1, it opens a gui with some options, button 2, another gui with other options etc etc. And those other guis should have other buttons which may lead to other guis or to other option.

This is how I would like it:

$MainGui=Guicreate(blahblah)

$button1=Guictrlcreatebutton(blahblah)

$button2=same as above

$button3=same as above

While 1

$msg=GuiGetMsg

If $smg= guieventclose then exitloop

Switch

case $msg=$button1

Open another gui with some functions, the main gui should be unclicable, unselectable, or either disappear if none of the precedent are possible.

case $msg=$button2

Open the second gui with other function

case $msg=$button3

Open a third gui with some buttons in it

Then how to start a new cycle that gets inputs buttons of the $button3 gui? I just nest another while or guigetmsg under $msg=$button3?

Heres the code im trying:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$GuiPrincipale = GUICreate("Form1", 458, 497, 287, 107)
$LabelSalute = GUICtrlCreateLabel("Salute: "&$Salute&"%", 208, 48, 90, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
$BottoneUscite = GUICtrlCreateButton("Button1", 336, 56, 105, 33, $WS_GROUP);BOTTONE USCITE
$Button2 = GUICtrlCreateButton("Button2", 336, 100, 105, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1;CICLO CHECK
$SceltaGUIPrincipale = GUIGetMsg()
If $SceltaGUIPrincipale=$GUI_EVENT_CLOSE Then Exitloop;CHIUDE GUI PRINCIPALE SE PIGIO X ROSSA
Switch $SceltaGUIPrincipale
    Case $SceltaGUIPrincipale=$BottoneUscite;APRE GUI BOTTONE USCITE
         $Form1 = GUICreate("Form1", 530, 513, 180, 132,-1,-1,$GuiPrincipale)
$Pic1 = GUICtrlCreatePic(@ScriptDir&"\Locali\Prestige.JPG", 24, 152, 241, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Label1", 280, 152, 220, 89)
$Button1 = GUICtrlCreateButton("Button1", 272, 256, 233, 33, $WS_GROUP)
$Pic2 = GUICtrlCreatePic(@ScriptDir&"\Locali\losi.jpg", 24, 16, 241, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Button2 = GUICtrlCreateButton("Button2", 272, 112, 233, 33, $WS_GROUP)

GUISetState(@SW_SHOW)


EndSwitch
WEnd

By executing this script (which I shortened a lot as gui codes and other functions were adding up lot of lines) it just shows me the 2 guis (2 for now, I'm planning to put more) and the second loops infinitely blinking on the screen. I want that if i presso BottoneUscite the main gui is unselectable/unclicable or disappears and that the second gui pops out. As u can see here $Form1 = GUICreate("Form1", 530, 513, 180, 132,-1,-1,$GuiPrincipale) I also tried to parent this to Main gui but sorted no effect. To be honest, I didn't even understood what's parenting for.

How I could solve this?

Thanks for your time.

Share this post


Link to post
Share on other sites
slayerz

Your Switch statement is wrong

Case $SceltaGUIPrincipale=$BottoneUscite;APRE GUI BOTTONE USCITE

You should use

Case $BottoneUscite;APRE GUI BOTTONE USCITE
Edited by slayerz

AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites
niubbone

Your Switch statement is wrong

Case $SceltaGUIPrincipale=$BottoneUscite;APRE GUI BOTTONE USCITE

You should use

Case $BottoneUscite;APRE GUI BOTTONE USCITE

OW! thanks!

No idea about that. I always saw example in where a case was:

Case $variable=$buttonispressed

do things

So i had no idea i had to put the $buttonispressed alone.

Any other hints about making the Main gui unclickable/Unselectable?

And also, how do I make that if red x is pressed in the second gui, then you get back to main?

Share this post


Link to post
Share on other sites
slayerz

I have some spare time + nothing to do, so I will help you this time

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$GuiPrincipale = GUICreate("Parent", 458, 497, 287, 107)
$LabelSalute = GUICtrlCreateLabel("Salute: ", 208, 48, 90, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
$BottoneUscite = GUICtrlCreateButton("Button1", 336, 56, 105, 33, $WS_GROUP);BOTTONE USCITE
$BottoneUscite2 = GUICtrlCreateButton("Button2", 336, 100, 105, 33, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1;CICLO CHECK
    $SceltaGUIPrincipale = GUIGetMsg()

    If $SceltaGUIPrincipale = $GUI_EVENT_CLOSE Then Exitloop;CHIUDE GUI PRINCIPALE SE PIGIO X ROSSA

    Switch $SceltaGUIPrincipale
        Case $BottoneUscite;APRE GUI BOTTONE USCITE
            $Form1 = GUICreate("Child1", 530, 513, 180, 132,-1,-1,$GuiPrincipale)
            $Pic1 = GUICtrlCreatePic(@ScriptDir&"\Locali\Prestige.JPG", 24, 152, 241, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Label1 = GUICtrlCreateLabel("Label1", 280, 152, 220, 89)
            $Button1 = GUICtrlCreateButton("Button1", 272, 256, 233, 33, $WS_GROUP)
            $Pic2 = GUICtrlCreatePic(@ScriptDir&"\Locali\losi.jpg", 24, 16, 241, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Button2 = GUICtrlCreateButton("Button2", 272, 112, 233, 33, $WS_GROUP)

            GUISetState(@SW_SHOW)
            GUISetState(@SW_DISABLE, $GuiPrincipale)

            While 1
                $child1 = GUIGetMsg()
                If $child1 = $GUI_EVENT_CLOSE Then Exitloop
            WEnd

            GUISetState(@SW_ENABLE, $GuiPrincipale)
            GUIDelete($Form1)
        Case $BottoneUscite2
            $Form2 = GUICreate("Child2", 530, 513, 180, 132,-1,-1,$GuiPrincipale)
            $Pic1 = GUICtrlCreatePic(@ScriptDir&"\Locali\Prestige.JPG", 24, 152, 241, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Label1 = GUICtrlCreateLabel("Label1", 280, 152, 220, 89)
            $Button1 = GUICtrlCreateButton("Button1", 272, 256, 233, 33, $WS_GROUP)
            $Pic2 = GUICtrlCreatePic(@ScriptDir&"\Locali\losi.jpg", 24, 16, 241, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Button2 = GUICtrlCreateButton("Button2", 272, 112, 233, 33, $WS_GROUP)

            GUISetState(@SW_SHOW)
            GUISetState(@SW_DISABLE, $GuiPrincipale)

            While 1
                $child2 = GUIGetMsg()
                If $child2 = $GUI_EVENT_CLOSE Then Exitloop
            WEnd

            GUISetState(@SW_ENABLE, $GuiPrincipale)
            GUIDelete($Form2)
    EndSwitch
WEnd

Edit : BTW, the one that you're mentioned is Select statement, not Switch

Edited by slayerz

AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites
niubbone

I have some spare time + nothing to do, so I will help you this time

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$GuiPrincipale = GUICreate("Parent", 458, 497, 287, 107)
$LabelSalute = GUICtrlCreateLabel("Salute: ", 208, 48, 90, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
$BottoneUscite = GUICtrlCreateButton("Button1", 336, 56, 105, 33, $WS_GROUP);BOTTONE USCITE
$BottoneUscite2 = GUICtrlCreateButton("Button2", 336, 100, 105, 33, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1;CICLO CHECK
    $SceltaGUIPrincipale = GUIGetMsg()

    If $SceltaGUIPrincipale = $GUI_EVENT_CLOSE Then Exitloop;CHIUDE GUI PRINCIPALE SE PIGIO X ROSSA

    Switch $SceltaGUIPrincipale
        Case $BottoneUscite;APRE GUI BOTTONE USCITE
            $Form1 = GUICreate("Child1", 530, 513, 180, 132,-1,-1,$GuiPrincipale)
            $Pic1 = GUICtrlCreatePic(@ScriptDir&"\Locali\Prestige.JPG", 24, 152, 241, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Label1 = GUICtrlCreateLabel("Label1", 280, 152, 220, 89)
            $Button1 = GUICtrlCreateButton("Button1", 272, 256, 233, 33, $WS_GROUP)
            $Pic2 = GUICtrlCreatePic(@ScriptDir&"\Locali\losi.jpg", 24, 16, 241, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Button2 = GUICtrlCreateButton("Button2", 272, 112, 233, 33, $WS_GROUP)

            GUISetState(@SW_SHOW)
            GUISetState(@SW_DISABLE, $GuiPrincipale)

            While 1
                $child1 = GUIGetMsg()
                If $child1 = $GUI_EVENT_CLOSE Then Exitloop
            WEnd

            GUISetState(@SW_ENABLE, $GuiPrincipale)
            GUIDelete($Form1)
        Case $BottoneUscite2
            $Form2 = GUICreate("Child2", 530, 513, 180, 132,-1,-1,$GuiPrincipale)
            $Pic1 = GUICtrlCreatePic(@ScriptDir&"\Locali\Prestige.JPG", 24, 152, 241, 137, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Label1 = GUICtrlCreateLabel("Label1", 280, 152, 220, 89)
            $Button1 = GUICtrlCreateButton("Button1", 272, 256, 233, 33, $WS_GROUP)
            $Pic2 = GUICtrlCreatePic(@ScriptDir&"\Locali\losi.jpg", 24, 16, 241, 129, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
            $Button2 = GUICtrlCreateButton("Button2", 272, 112, 233, 33, $WS_GROUP)

            GUISetState(@SW_SHOW)
            GUISetState(@SW_DISABLE, $GuiPrincipale)

            While 1
                $child2 = GUIGetMsg()
                If $child2 = $GUI_EVENT_CLOSE Then Exitloop
            WEnd

            GUISetState(@SW_ENABLE, $GuiPrincipale)
            GUIDelete($Form2)
    EndSwitch
WEnd

Edit : BTW, the one that you're mentioned is Select statement, not Switch

Thanks... I probabily would never figured out how to do that... seems complicated to get this without specific knowledge

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.