Sign in to follow this  
Followers 0
Bokkie

Display a form and then another form.

3 posts in this topic

#1 ·  Posted (edited)

I'm prototyping a sample form using the GUI controls. I created a form and added a button. In the message loop I want to create another form. Then when that form is closed control reverts back to the original.

The second form is displayed ok but when I close it, both it and the parent form are closed. Are sub-forms allowed or am I failing to do something properly. Here is the 'dirty' code I've got so far:

#include <GUIConstants.au3>

GUICreate("Test Form", 270, 180, -1, -1)

$buttonLeft = 5

$buttonTop = 5

$buttonWidth = 100

$buttonHeight = 25

$button1 = GUICtrlCreateButton("Install A", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)

$buttonTop = $buttonTop + $buttonHeight + 5

$button2 = GUICtrlCreateButton("Install B", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)

$label1 = GUICtrlCreateLabel("", 185, 50, 70, 25, 0x1000)

$label2 = GUICtrlCreateLabel("", 185, 25, 70, 25, 0x1000)

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $button1

GUICtrlSetData($label2, "1")

GUICtrlSetData($label1, "1")

GUICreate("Test Form", 270, 180, -1, -1)

GuiSetState()

; Not sure what to do at this point???????

Case $msg = $button2

$results = "2"

GUICtrlSetData($label2, $results)

GUICtrlSetData($label1, "2")

EndSelect

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

Any ideas what I need to do?

Edited by Peter Hamilton-Scott

Share this post


Link to post
Share on other sites



I'm prototyping a sample form using the GUI controls. I created a form and added a button. In the message loop I want to create another form. Then when that form is closed control reverts back to the original.

The second form is displayed ok but when I close it, both it and the parent form are closed. Are sub-forms allowed or am I failing to do something properly. Here is the 'dirty' code I've got so far:

#include <GUIConstants.au3>

GUICreate("Test Form", 270, 180, -1, -1)

$buttonLeft = 5

$buttonTop = 5

$buttonWidth = 100

$buttonHeight = 25

$button1 = GUICtrlCreateButton("Install A", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)

$buttonTop = $buttonTop + $buttonHeight + 5

$button2 = GUICtrlCreateButton("Install B", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)

$label1 = GUICtrlCreateLabel("", 185, 50, 70, 25, 0x1000)

$label2 = GUICtrlCreateLabel("", 185, 25, 70, 25, 0x1000)

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $button1

GUICtrlSetData($label2, "1")

GUICtrlSetData($label1, "1")

GUICreate("Test Form", 270, 180, -1, -1)

GuiSetState()

; Not sure what to do at this point???????

Case $msg = $button2

$results = "2"

GUICtrlSetData($label2, $results)

GUICtrlSetData($label1, "2")

EndSelect

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

Any ideas what I need to do?

you should assign variables to your GUICreate()'s. that way you can reference each of the windows specifically. also on $GUI_EVENT_CLOSE event, you can check which window is supposed to close, and kill that window.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

$gui1 = GUICreate ("Test Form", 270, 180, -1, -1)

$buttonLeft = 5
$buttonTop = 5
$buttonWidth = 100
$buttonHeight = 25
$button1 = GUICtrlCreateButton("Install A", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)
$buttonTop = $buttonTop + $buttonHeight + 5
$button2 = GUICtrlCreateButton("Install B", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)
$label1 = GUICtrlCreateLabel("", 185, 50, 70, 25, 0x1000)
$label2 = GUICtrlCreateLabel("", 185, 25, 70, 25, 0x1000)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $button1
         GUICtrlSetData($label2, "1")
         GUICtrlSetData($label1, "1")
         GUISetState(@SW_DISABLE, $gui1)
         $gui2 = GUICreate("Test Form 2", 270, 180, -1, -1)
         GUISetState()
         While 1
            $msg2 = GUIGetMsg()
            Select
               Case $msg2 = $GUI_EVENT_CLOSE
                  ExitLoop
            EndSelect
         WEnd
         GUISetState(@SW_ENABLE, $gui1)
         GUIDelete($gui2)
         
        ; Not sure what to do at this point???????
      Case $msg = $button2
         $results = "2"
         GUICtrlSetData($label2, $results)
         GUICtrlSetData($label1, "2")
   EndSelect
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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