seres

delete a gui with command

4 posts in this topic

#1 ·  Posted

Im trying to delete a gui with a command, my problem is that the delete doesnt recognize the gui created

 

If $vFlagBlack = True Then
        $gui = GuiCreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP);
        GuiSetState(@SW_SHOW);
        WinSetOnTop($gui, "", 1);
        GuiSetBkColor("0x000000");
        $vFlagBlack = False
    Else
        GUIDelete($gui)
        $vFlagBlack = True
    EndIf

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstants.au3>

Global $hMain = GUICreate("Main", 120, 45)
Global $btnExample = GUICtrlCreateButton("Create GUI", 10, 10, 100, 25)
Global $hExample = Null

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $btnExample
            ; The $hExample GUI Exists
            If ($hExample) Then
                GUIDelete($hExample)
                $hExample = Null
            ; The $hExample GUI does not exist
            Else
                $hExample = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
                GUISetState(@SW_SHOW, $hExample)
            EndIf
    EndSwitch
WEnd

Try this.

Edited by InunoTaishou

Share this post


Link to post
Share on other sites

#3 ·  Posted

You need to declare $gui before if

works for me

Global $vFlagBlack = True, $gui

Func a()
    If $vFlagBlack = True Then
        $gui = GuiCreate("", @DesktopWidth, @DesktopHeight, 0, 0);
        GuiSetState(@SW_SHOW);
        WinSetOnTop($gui, "", 1);
        GuiSetBkColor("0x000000");
        $vFlagBlack = False
    Else
        GUIDelete($gui)
        $vFlagBlack = True
    EndIf
EndFunc

a()
Sleep(2000)
a()

 


Sorry for my english :)

Share this post


Link to post
Share on other sites

#4 ·  Posted

31 minutes ago, InunoTaishou said:
#include <GUIConstants.au3>

Global $hMain = GUICreate("Main", 120, 45)
Global $btnExample = GUICtrlCreateButton("Create GUI", 10, 10, 100, 25)
Global $hExample = Null

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $btnExample
            ; The $hExample GUI Exists
            If ($hExample) Then
                GUIDelete($hExample)
                $hExample = Null
            ; The $hExample GUI does not exist
            Else
                $hExample = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
                GUISetState(@SW_SHOW, $hExample)
            EndIf
    EndSwitch
WEnd

Try this.

thanks it worked :)

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