Jump to content

MsgBox Retry Cancel bug?


Recommended Posts

Once the user presses retry the MsgBox should close and you should be able to change stuff, but as of yet the whole program closes?

Ps. Here a part of the code.

Func _GUI()
GUISetState(@SW_SHOW, $main)
While 1 ;~ = true
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $btnManual
$varElectosVersion = GUICtrlRead($hCombo)
$varElectosVersionDash = StringReplace($varElectosVersion,".","-") ;Replaces the . for a - for use in the .sws and .ws.
MsgBox(0,"varElectosVersion",$varElectosVersion)
If $varElectosVersion = "" Then
$RetryCancel = MsgBox(48 + 5, "Electos Version", "Error, please select an Electos version.")
Switch $RetryCancel
Case 4 ;Retry
Return
Case 2 ;Cancel
Exit
EndSwitch
EndIf

Tell me if you need more info.

Link to comment
Share on other sites

  • Moderators

YoshiKlarenbeek,

That is most certainly NOT the answer as you start an infinite recursive loop by recalling the function inside itself. Read the Recursion tutorial in the Wiki to understand why this is a bad thing. :(

All you need to do is to simply ignore that return value - then you return to the main loop and wait for another button press: ;)

#include <GUIConstantsEx.au3>

_GUI()

Func _GUI()
    $main = GUICreate("Test", 500, 500)
    $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
    GUICtrlSetData(-1, "1.1|1.2|1.3")
    $btnManual = GUICtrlCreateButton("Go", 10, 200, 80, 30)
    GUISetState(@SW_SHOW, $main)
    While 1 ;~ = true
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $btnManual
                $varElectosVersion = GUICtrlRead($hCombo)
                $varElectosVersionDash = StringReplace($varElectosVersion, ".", "-") ;Replaces the . for a - for use in the .sws and .ws.
                MsgBox(0, "varElectosVersion", $varElectosVersion)
                If $varElectosVersion = "" Then
                    $RetryCancel = MsgBox(48 + 5, "Electos Version", "Error, please select an Electos version.")
                    Switch $RetryCancel
                        Case 2 ;Cancel
                            Exit
                    EndSwitch
                EndIf
        EndSelect
    WEnd
EndFunc   ;==>_GUI

All clear? :)

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

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...