Jump to content
Sign in to follow this  
jakub

GUIDelete()

Recommended Posts

jakub

i want to delete gui after i use it but it stays visible when next (in this example just msgbox) gui is launched

#include <GUIConstants.au3>

$dysc=InputBox2("aaaaaa,bbbbb","aaaaaa")
msgbox(0,"","")



Func inputbox2($title,$label)

$GUIinput=GUICreate ($title,300,100,-1,-1,-1,-1)
$Input=GUICtrlCreateInput("",20,40,260,20)
$OK=GUICtrlCreateButton("ok",250,70,30,20,$BS_DEFPUSHBUTTON)
$COPY=GUICtrlCreateButton("Copy",200,70,50,20)
$GUIInputLabel=GUICtrlCreateLabel($label,20,10)

GUISetState()
While 1
    $msg=GUIGetMsg()

    Select
    Case $msg=$GUI_EVENT_CLOSE
    ExitLoop
    Case $msg=$OK
    Return GUICtrlRead($input)
    ExitLoop
    Case $msg=$COPY
    Return $title
    
    ExitLoop
    EndSelect
    
WEnd
GUIDelete($GUIinput)
EndFunc

Share this post


Link to post
Share on other sites
Generator

Here is a fix..the reason is Return Exits a function and return data right after the line is being executed. So you won't be able to get to next line which it deletes the GUI

#include <GUIConstants.au3>

$dysc = inputbox2("aaaaaa,bbbbb", "aaaaaa")
GUIDelete($GUIinput)
MsgBox(0, "", "")



Func inputbox2($title, $label)

    Global $GUIinput = GUICreate($title, 300, 100, -1, -1, -1, -1)
    $Input = GUICtrlCreateInput("", 20, 40, 260, 20)
    $OK = GUICtrlCreateButton("ok", 250, 70, 30, 20, $BS_DEFPUSHBUTTON)
    $COPY = GUICtrlCreateButton("Copy", 200, 70, 50, 20)
    $GUIInputLabel = GUICtrlCreateLabel($label, 20, 10)

    GUISetState()
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $OK
                Return GUICtrlRead($Input)
            Case $msg = $COPY
                Return $title
        EndSelect

    WEnd
EndFunc  ;==>inputbox2

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  

×