Jump to content

GUI help needed again D:


Ultima2
 Share

Recommended Posts

#include <GUIConstants.au3>
Func third()
    GUICreate("test",800,500)
    $A3value = GUICtrlCreateInput("",10,50,30,30)
    $B3value = GUICtrlCreateInput("", 70, 50, 30, 30)
    $C3value = GUICtrlCreateInput("", 130, 50, 30, 30)
    $D3value = GUICtrlCreateInput('', 190, 50, 30, 30)
    $ok3button = GUICtrlCreateButton("ok", 20, 200)
    $negative3 = GUICtrlCreateInput("", 30, 130, 40, 22)
    $posistive3 = GUICtrlCreateInput("", 210, 130, 40, 22)
    $exit3button = GUICtrlCreateButton("Exit", 40, 200)
    GUISetState()
EndFunc
GUICreate("test",800,500)
$2Button = GUICtrlCreateButton("something", 700, 40)
$3Button = GUICtrlCreateButton("else", 700, 70)
GUISetState()
Do
    $msg = GUIgetmsg()
    Select
    Case $msg = $3Button
        Call ("third")
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

So my GUI will create a child GUI when I click the button "else". How do I write so that if I exit the child GUI, I will still have the main GUI? Thanks

Edited by Ultima2
Link to comment
Share on other sites

#include <GUIConstants.au3>
Func third()
    GUICreate("test",800,500)
    $A3value = GUICtrlCreateInput("",10,50,30,30)
    $B3value = GUICtrlCreateInput("", 70, 50, 30, 30)
    $C3value = GUICtrlCreateInput("", 130, 50, 30, 30)
    $D3value = GUICtrlCreateInput('', 190, 50, 30, 30)
    $ok3button = GUICtrlCreateButton("ok", 20, 200)
    $negative3 = GUICtrlCreateInput("", 30, 130, 40, 22)
    $posistive3 = GUICtrlCreateInput("", 210, 130, 40, 22)
    $exit3button = GUICtrlCreateButton("Exit", 40, 200)
    GUISetState()
EndFunc
GUICreate("test",800,500)
$2Button = GUICtrlCreateButton("something", 700, 40)
$3Button = GUICtrlCreateButton("else", 700, 70)
GUISetState()
Do
    $msg = GUIgetmsg()
    Select
    Case $msg = $3Button
        Call ("third")
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

So my GUI will create a child GUI when I click the button "else". How do I write so that if I exit the child GUI, I will still have the main GUI? Thanks

There is at least two ways of doing this. I went with show / hide of the second GUI, instead of GUIDelete (). And used Zedna's suggestion of using GUIGetMsg(1).

I trust you can change it to suite your own needs.

#include <GUIConstants.au3>

Global $hMain, $hGUI2, $exit3button, $ok3button
Global $A3value, $B3value, $C3value, $D3value, $negative3, $posistive3
Global $A3input, $B3input, $C3input, $D3input

$hMain = GUICreate("test", 800, 500)
$2Button = GUICtrlCreateButton("something", 700, 40, 60, 25)
$3Button = GUICtrlCreateButton("else", 700, 66, 60, 25)
GUISetState()
third()
GUISetState(@SW_HIDE, $hGUI2)

While 1
    $msg = GUIGetMsg(1) ; 1 = returns an array containing the event and extended information.
    Select
        Case $msg[0] = $3Button
            GUISetState(@SW_SHOW, $hGUI2)
            
        Case $msg[0] = $GUI_EVENT_CLOSE
            If $hGUI2 = $msg[1] Then GUISetState(@SW_HIDE, $hGUI2) ; Hide $GUI2
            If $hMain = $msg[1] Then Exit
            
        Case $msg[0] = $ok3button ; Hide $GUI2
            $A3value = GUICtrlRead($A3input) ; These had to go somewhere.
            $B3value = GUICtrlRead($B3input)
            $C3value = GUICtrlRead($C3input)
            $D3value = GUICtrlRead($D3input)
            GUISetState(@SW_HIDE, $hGUI2)
            
        Case $msg[0] = $exit3button
            Exit
            
        Case $msg[0] = $2Button
            MsgBox(0, "", "Contents of input Control (handle:$A3input) is " & $A3value)
            
    EndSelect
WEnd

Func third()
    $hGUI2 = GUICreate("test", 800, 500)
    $A3input = GUICtrlCreateInput("A3", 10, 50, 30, 30)
    $B3input = GUICtrlCreateInput("", 70, 50, 30, 30)
    $C3input = GUICtrlCreateInput("", 130, 50, 30, 30)
    $D3input = GUICtrlCreateInput('', 190, 50, 30, 30)
    $ok3button = GUICtrlCreateButton("ok", 20, 200, 30, 25)
    $negative3 = GUICtrlCreateInput("", 30, 130, 40, 22)
    $posistive3 = GUICtrlCreateInput("", 210, 130, 40, 22)
    $exit3button = GUICtrlCreateButton("Exit", 50, 200, 30, 25)
    GUISetState()
EndFunc   ;==>third
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...