Jump to content

Close a second GUI


Recommended Posts

  • Moderators

SvenMawby,

Use GUIGetMsg with the "advanced" parameter so that you can tell the GUI from which you are receiving the $GUI_EVENT_CLOSE message. Then you can either Exit the whole script or GUIDelete the second GUI. :idea:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

SvenMawby,

Saying "please" ususally works: :idea:

#include <GUIConstantsEx.au3>

Global $hNewGUI = 9999

$hGUI = GUICreate("Test", 500, 500)

$hButton = GUICtrlCreateButton("New GUI", 10, 10, 80, 30)

GUISetState()

While 1
    ; Note you get an array returned
    $aMsg = GUIGetMsg(1)
    ; Which GUI?
    Switch $aMsg[1]
        Case $hGUI
            ; Which control on the GUI?
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hButton
                    GUICtrlSetState($hButton, $GUI_DISABLE)
                    $hNewGUI = GUICreate("New GUI", 300, 300)

                    $hNewButton = GUICtrlCreateButton("New Button", 10, 10, 80, 30)

                    GUISetState()
            EndSwitch
        Case $hNewGUI
            ; Which control on the GUI?
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIDelete($hNewGUI)
                    GUICtrlSetState($hButton, $GUI_ENABLE)
                Case $hNewButton
                    MsgBox(0, "Hi", "I am on the New GUI")
            EndSwitch
    EndSwitch

WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

SvenMawby,

If you want help, a few tips: :(

1. Ask a proper question - "a'm worried" gives absolutely no clue as to what we are supposed to be helping you with. :idea:

2. Post code which does not come up with umpteen errors and warnings. If you have this line in your script:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

to highlight those errors, then correct what it shows you is wrong BEFORE you post the script. We will help with major problems, but you should be able to deal with these minor errors yourself.

3. Try and get your code into a reasonable format. Scripts with large areas of white space and indentation all over the place do not help debugging. If you have the full SciTE4AutoIt3 package (which you can download from here) then you will find a very helpful utility called Tidy in the <Tools> menu which does a good job for you. :)

When you have a script which will not take us a considerable time to sort out BEFORE we can even begin to see what else might be wrong with it, try posting again. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

SvenMawby,

i dont knew that there was a new version of autoit

It is not a new version of AutoIt, it is a bigger, better version of the editor SciTE. The normal install only gives you a cut-down version of the editor - the link will let you install the full version. :idea:

As to your problem, here is the code which creates your main GUI and part of your GUIGetMsg loop:

;main gui
$gui = GUICreate("BAM Launcher " & $version, 700, 500, 170, -1, $WS_BORDER)
;$background = GUICtrlCreatePic("bg.bmp", 0, 0, 700, 500, 0)
GUISetBkColor(0)
$button1 = GUICtrlCreateButton("button", 5, 100, 300, 40, $BS_BITMAP)
GUICtrlSetImage($button1, "button.bmp")
$button2 = GUICtrlCreateButton("Forum", 5, 150, 300, 40)
$button3 = GUICtrlCreateButton("Server", 5, 200, 300, 40)
$button4 = GUICtrlCreateButton("Downloads", 5, 250, 300, 40)
;/main gui

; ----------

$aMsg = GUIGetMsg(1)
    ; Which GUI?
    Switch $aMsg[1]
        Case $gui
            ; Which control on the GUI?
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE Or $cancelbutton
                    Exit

You ask the loop to look out for $cancelbutton - but you have not created a control of that name in the GUI. :) And so you get an error.

M23

Edit: And the correct syntax would anyway be:

Case $GUI_EVENT_CLOSE, $cancelbutton

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

SvenMawby,

You cannot give controls on different GUIs the same name - otherwise you keep overwriting the variable and only the last-created is ever actioned.

You also need to declare the other GUI names as Global variables at the start of your script or you will get "undeclared" errors when the Switch structure looks for them.

Take a look at this: :idea:

<snip>

Top Tip: get the GUI part of your script sorted BEFORE you start adding anything else. Otherwise the script get cluttered and it is hard to see what is going on. :)

M23

Edited by Melba23
Code removed at OP's request

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

SvenMawby,

Global $dl = 9999, $srv = 9999

You must declare the variables as I explained, but if you leave them without a value, they fire every time you go through the loop. So you must give them a dummy value that is unlikely to be used (or are you going to have more than 10000 controls in your GUI? :) )

Looking at your images, I imagine the graphic artefacts are there because you have resized your image. Images always look best if you display them at their original size. :idea:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 3 years later...
  • Moderators

MrNymous,

I am not at all amused by your actions in this thread. A simple PM asking me to remove any sensitive data would have sufficed rather than just deleting all your posts and so ruining the thread for anyone else who might have been interested in the general topic. If you do such a thing again sanctions will follow. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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