Jump to content

Unload / Destroy Gui Object


Recommended Posts

Im looking for a gui object destroy command or something similar.

I've been messing with another application I am working on which loaded different media players.

The problem i am running into is that I cant seem to remove the player once loaded. So additionnal players just overlap.

Here is an examle using a button.

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$loaded = False
$Form1 = GUICreate("AForm1", 300, 340, 192, 125)
$Button2 = GUICtrlCreateButton("Load / Unload", 104, 256, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button2
        onoff()
    Case Else
;;;;;;;
    EndSelect
WEnd
Exit

Func onoff()
    If $loaded ==False Then
        $Button1 = 0
        $Button1 = GUICtrlCreateButton("AButton1", 64, 24, 169, 81)
        $loaded=True
    ElseIf $loaded ==True Then
        $Button1 = 0
;;WHY WONT IT GO AWAY!
        $loaded = False
    EndIf
EndFunc
Edited by Emerica
Link to comment
Share on other sites

maybe

#include <GUIConstants.au3>
; == GUI generated with Koda ==

Dim $AButton1

$loaded = False
$Form1 = GUICreate("AForm1", 300, 340, 192, 125)
$Button2 = GUICtrlCreateButton("Load / Unload", 104, 256, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button2
        onoff()
    Case Else
;;;;;;;
    EndSelect
WEnd
Exit

Func onoff()
    If $loaded ==False Then
        $Button1 = 0
        $AButton1 = GUICtrlCreateButton("AButton1", 64, 24, 169, 81)
        $loaded=True
    ElseIf $loaded ==True Then
        $Button1 = 0
        GUICtrlDelete($AButton1)
;;WHY WONT IT GO AWAY!
        $loaded = False
    EndIf
EndFunc

8)

NEWHeader1.png

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