Jump to content

gui question, about multiple windows


Recommended Posts

i made a script to show what i'm talking about...press the button to make "Form2" gui, when "Form2" is closed, "Form1" gets closed too, how can i get only "Form2" to close?

CODE
#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 633, 447, 193, 125)

$Button1 = GUICtrlCreateButton("Press Here", 96, 96, 441, 257, 0)

GUICtrlSetFont(-1, 67, 400, 0, "Courier")

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Button1

GUICreate("Form2")

GUISetState(@SW_SHOW)

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

You can always count on me for the dumb questions ;)My Scripts:Rikku

Link to comment
Share on other sites

i made a script to show what i'm talking about...press the button to make "Form2" gui, when "Form2" is closed, "Form1" gets closed too, how can i get only "Form2" to close?

CODE
#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 633, 447, 193, 125)

$Button1 = GUICtrlCreateButton("Press Here", 96, 96, 441, 257, 0)

GUICtrlSetFont(-1, 67, 400, 0, "Courier")

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Button1

GUICreate("Form2")

GUISetState(@SW_SHOW)

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Here are a couple of ways.

#include <GUIConstants.au3>

$form2 = 0
$current = 0
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$Button1 = GUICtrlCreateButton("Press Here", 96, 96, 441, 257, 0)
GUICtrlSetFont(-1, 67, 400, 0, "Courier")
GUISetState(@SW_SHOW)
one()
msgbox(262144,"First way done", "Now try second way")
two()
Func one()
While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $Button1
            if $Form2 = 0 Then
            $Form2 = GUICreate("Form2")
            ConsoleWrite($form2 & @CRLF)
            GUISetState(@SW_SHOW)
            EndIf
        Case $GUI_EVENT_CLOSE
            If $nMsg[1] = $form2 Then 
              GUIDelete($Form2)
              $Form2 = 0
          Else
              Exitloop
          EndIf
          
    EndSwitch

WEnd

EndFunc

Func two()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            if $Form2 = 0 Then
            $Form2 = GUICreate("Form2")
            ConsoleWrite($form2 & @CRLF)
            GUISetState(@SW_SHOW)
            EndIf
        Case $GUI_EVENT_CLOSE
            $current = WinGetHandle(WIngettitle(""))
              GUIDelete($current)
            if $current = $Form1 then Exitloop
          
    EndSwitch

WEnd

EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...