Jump to content

If I have 2 GUI windows, how could I close only 1?


 Share

Recommended Posts

I have smth like this:

#include <GuiConstants.au3>

Opt("GUIOnEventMode", True)

GuiCreate("MyGUI", 312, 227,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1", 70, 20, 180, 40)
GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")
GUICtrlSetOnEvent($Button_1, "NewGui")

GuiSetState()

func terminate ()
    Exit
EndFunc

func NewGui ()
    Guicreate("MyGUI 2", 300, 200, 0, 0)
    $Button_2 = GUICtrlCreateButton("Button2", 70, 20, 180, 40)
    GUISetOnEvent($GUI_EVENT_CLOSE, "terminateNewGUI")
    GUICtrlSetOnEvent($Button_2, "test")
    
    GuiSetState()
EndFunc

func terminateNewGUI ()
;NOW, IF I WANT TO CLOSE ONLY NEW GUI WINDOW, WHAT SHOULD I WRITE HERE??? "EXIT" WON'T WORK COUSE IT WILL CLOSE THE FIRST GUI WINDOW TOO...
EndFunc

func test ()
    MsgBox(0, "test", "button works")
EndFunc


While 1
sleep (10)
WEnd

Can some tells me how can I close only 2nd gui window, without closing the first one?

Oh, and yeah, in my script I have many, many, many functions, and everytime I open SciTE they are all expanded, is there a way (one click, or similar) for me to shrink ("-") them all?

Edited by sandin
Link to comment
Share on other sites

This is one way

include <guiConstants.au3>

$gui1 = GuiCreate("Gui1",100,100,20,20)
GuiSetState()

$gui2 = GuiCreate("Gui2",100,100,140,20)
GuiSetState()

While 1
    $msg = GuiGetMsg(1)
    
    Switch $msg[0]
        
        Case $GUI_EVENT_CLOSE
            GuiDelete( $msg[1] )
            If NOT WinExists($gui1) and NOT WinExists($gui2) then Exitloop
        Case Else
    
    EndSwitch
        
WEnd
Link to comment
Share on other sites

#include <GuiConstants.au3>
Global $gui1, $gui2

Opt("GUIOnEventMode", True)

$gui1=GuiCreate("MyGUI", 312, 227,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1", 70, 20, 180, 40)
GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")
GUICtrlSetOnEvent($Button_1, "NewGui")

GuiSetState()

func terminate ()
    Exit
EndFunc

func NewGui ()
    $gui2=Guicreate("MyGUI 2", 300, 200, 0, 0)
    $Button_2 = GUICtrlCreateButton("Button2", 70, 20, 180, 40)
    GUISetOnEvent($GUI_EVENT_CLOSE, "terminateNewGUI")
    GUICtrlSetOnEvent($Button_2, "test")
    
    GuiSetState()
EndFunc

func terminateNewGUI ()
GUIDelete($gui2)
EndFunc

func test ()
    MsgBox(0, "test", "button works")
EndFunc


While 1
sleep (10)
WEnd

easy.....

:)

Link to comment
Share on other sites

U will have to call the two gui somthing.. fx gui1 and gui2

#include <GuiConstants.au3>

Opt("GUIOnEventMode", True)

$gui1 = GuiCreate("MyGUI", 312, 227,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1", 70, 20, 180, 40)
GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")
GUICtrlSetOnEvent($Button_1, "NewGui")

GuiSetState()

func terminate ()
    Exit
EndFunc

func NewGui ()
   $gui2 = Guicreate("MyGUI 2", 300, 200, 0, 0)
    $Button_2 = GUICtrlCreateButton("Button2", 70, 20, 180, 40)
    GUISetOnEvent($GUI_EVENT_CLOSE, "terminateNewGUI")
    GUICtrlSetOnEvent($Button_2, "test")
    
    GuiSetState()
EndFunc

func terminateNewGUI ()
GUICtrlDelete($gui2)
EndFunc

func test ()
    MsgBox(0, "test", "button works")
EndFunc


While 1
sleep (10)
WEnd
Edited by Kiesp

http://www.autoitscript.com/forum/index.php?showtopic=69911 <-- Best hacker ever :D

Link to comment
Share on other sites

This is how to do it in your code

#include <GuiConstants.au3>

Opt("GUIOnEventMode", True)

GuiCreate("MyGUI", 312, 227,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Button1", 70, 20, 180, 40)
GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")
GUICtrlSetOnEvent($Button_1, "NewGui")

GuiSetState()

func terminate ()
    Exit
EndFunc

func NewGui ()
    Guicreate("MyGUI 2", 300, 200, 0, 0)
    $Button_2 = GUICtrlCreateButton("Button2", 70, 20, 180, 40)
    GUISetOnEvent($GUI_EVENT_CLOSE, "terminateNewGUI")
    GUICtrlSetOnEvent($Button_2, "test")
    
    GuiSetState()
EndFunc

func terminateNewGUI ()
    GuiDelete(@GUI_WINHANDLE )
;NOW, IF I WANT TO CLOSE ONLY NEW GUI WINDOW, WHAT SHOULD I WRITE HERE??? "EXIT" WON'T WORK COUSE IT WILL CLOSE THE FIRST GUI WINDOW TOO...
EndFunc

func test ()
    MsgBox(0, "test", "button works")
EndFunc


While 1
sleep (10)
WEnd
Edited by ChrisL
Link to comment
Share on other sites

oh lol, thank you :)

what about my other issuie? Shrinking all func. on 1 click? is it posible?

WinMinimizeAll() and WinMinimizeAllUndo().

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

WinMinimizeAll() and WinMinimizeAllUndo().

:)

I think he means in Scite where you can click the minus sign next to a function or a loop and close that group up he wants to close them all up with 1 click or default open an au3 script with them all closed up. Jdeb is the man for this question I think

Edited by ChrisL
Link to comment
Share on other sites

oh lol, thank you :)

what about my other issuie? Shrinking all func. on 1 click? is it posible?

Scite View menu|Toggle all folds

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

I think he means in Scite where you can click the minus sign next to a function or a loop and close that group up he wants to close them all up with 1 click or default open an au3 script with them all closed up. Jdeb is the man for this question I think

Yep, didn't read closely enough...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...