Jump to content
Sign in to follow this  
bobbintb

help deleting a gui

Recommended Posts

bobbintb

i have a gui that i am trying to create a preferences window for. my problem is i cant figure out a way to close the second gui without closing them both. and if i try to use guidelete or set the state to hidden, none of the control in the first gui respond. i just dont know the command im looking for.

Share this post


Link to post
Share on other sites
Valuater

We can not out-guess your coded direction...aka we are not mind readers

Either post the code you have, or trim it down to a small script that will replicate the problem

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
enaiman

GuiDelete needs to have specified which GUI needs to be deleted.

Here it is an example:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 212, 157, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Button1", 72, 80, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
Global $Form2
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    $Form2 = GUICreate("Form2", 212, 157, 292, 224)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
    $Button1 = GUICtrlCreateButton("Button2", 72, 80, 75, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, "Button2Click")
    GUISetState(@SW_SHOW)
EndFunc
Func Form1Close()
    Exit
EndFunc
Func Button2Click()
    MsgBox(0, "Info", "Button 2 clicked")
EndFunc
Func Form2Close()
    GUIDelete($Form2)
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Valuater

@above Hope you guessed correctly..

more-over, I hope the OP at least see's what you posted

Looks like he's been gone for a while now!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
bobbintb

i was on my way out so i didnt have time to post code:

Func prefs()
    $dir = IniRead("settings.ini", "prefs", "defaultdirectory", "default")
    $Form1 = GUICreate("Preferences", 445, 196, 558, 399)
    GUICtrlCreateLabel("Directory", 10, 50, 50)
    $txtSIFile = GUICtrlCreateInput($dir, 60, 45, 300, 20)
    GUICtrlSetTip(-1, "The Text of the splash window")
    $open = GUICtrlCreateButton("Open", 370, 45, 70, 20)
    GUICtrlSetTip(-1, "Show the Open File dialog box")
    $cancel = GUICtrlCreateButton("Cancel", 360, 160, 75, 25, $WS_GROUP)
    $ok = GUICtrlCreateButton("OK", 272, 160, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form1)
            Case $cancel
                GUIDelete($Form1)
            Case $ok
                IniWrite("settings.ini", "prefs", "defaultdirectory", $dir)
                GUIDelete($Form1)
            Case $open
                $dir = FileSelectFolder("Choose a folder", "")
                GUICtrlSetData($txtSIFile, $dir)
        EndSwitch
    WEnd
EndFunc ;==>prefs

Func maingui()
;   Menus
    $MenuFile = GUICtrlCreateMenu("&File")
    $MenuFileLoad = GUICtrlCreateMenuItem("Quick &Load List", $MenuFile)
    $MenuFileCreate = GUICtrlCreateMenuItem("Quick &Create List", $MenuFile)
    $separator1 = GUICtrlCreateMenuItem("", $MenuFile)
    $MenuManFileLoad = GUICtrlCreateMenuItem("Manual Load List", $MenuFile)
    $MenuManFileCreate = GUICtrlCreateMenuItem("Manual Create List", $MenuFile)
    $separator2 = GUICtrlCreateMenuItem("", $MenuFile)
    $MenuFileRestore = GUICtrlCreateMenuItem("&Restore", $MenuFile)
    $separator3 = GUICtrlCreateMenuItem("", $MenuFile)
    $MenuFileExit = GUICtrlCreateMenuItem("E&xit", $MenuFile)
    $MenuEdit = GUICtrlCreateMenu("&Edit")
    $MenuEditPrefs = GUICtrlCreateMenuItem("&Preferences", $MenuEdit)
;   End Menus
    $refresh = GUICtrlCreateButton("Refresh", 8, 400, 89, 25)
    $mylist = GUICtrlCreateListView("Available", 8, 8, 617, 370)
    _GUICtrlListView_SetColumnWidth($mylist, 0, 613)
    GUICtrlSetLimit(-1, 200); to limit horizontal scrolling
    list()
;   $close = GUICtrlCreateButton("Exit", 512, 408, 113, 25)
    GUISetState()
    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $MenuFileExit
                Exit
            Case $msg = $MenuFileCreate
                createlist()
            Case $msg = $MenuFileRestore
                restoretracker()
            Case $msg = $refresh
                list()
            Case $msg = $MenuEditPrefs
                prefs()
        EndSelect
    WEnd
EndFunc ;==>maingui
Edited by bobbintb

Share this post


Link to post
Share on other sites
GEOSoft

Func prefs()
    $dir = IniRead("settings.ini", "prefs", "defaultdirectory", "default")
    $Form1 = GUICreate("Preferences", 445, 196, 558, 399)
    GUICtrlCreateLabel("Directory", 10, 50, 50)
    $txtSIFile = GUICtrlCreateInput($dir, 60, 45, 300, 20)
    GUICtrlSetTip(-1, "The Text of the splash window")
    $open = GUICtrlCreateButton("Open", 370, 45, 70, 20)
    GUICtrlSetTip(-1, "Show the Open File dialog box")
    $cancel = GUICtrlCreateButton("Cancel", 360, 160, 75, 25, $WS_GROUP)
    $ok = GUICtrlCreateButton("OK", 272, 160, 75, 25, $WS_GROUP)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $Cancel
                GUIDelete($Form1)
                ExitLoop
            Case $ok
                IniWrite("settings.ini", "prefs", "defaultdirectory", $dir)
                GUIDelete($Form1)
                ExitLoop
            Case $open
                $dir = FileSelectFolder("Choose a folder", "")
                GUICtrlSetData($txtSIFile, $dir)
        EndSwitch
    WEnd
EndFunc ;==>prefs


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
bobbintb

that worked. thanks. i tried guidelete and exitloop but didnt think to put them together.

Share this post


Link to post
Share on other sites
GEOSoft

that worked. thanks. i tried guidelete and exitloop but didnt think to put them together.

Glad it helped. Notice that I also removed one of your Case statements. When using Switch Case, if you have multiple controls or events performing the same routines then just separate them with commas on the same Case line. If you are checking multiple consecutive controls then you can also use the keyword "To"

Case $Ctrl1 To $Ctrl6
      do_something()

or you could combine both

Case $Ctrl1, $Ctrl3 To $Ctrl6
      do_something()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
OchoNueve

Glad it helped. Notice that I also removed one of your Case statements. When using Switch Case, if you have multiple controls or events performing the same routines then just separate them with commas on the same Case line. If you are checking multiple consecutive controls then you can also use the keyword "To"

Case $Ctrl1 To $Ctrl6
      do_something()

or you could combine both

Case $Ctrl1, $Ctrl3 To $Ctrl6
      do_something()
Very cool, I had no idea

[font="Times New Roman"]Ocho.[/font]

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  

×