Jump to content

GUI/Forms and While Loops


Go to solution Solved by FireFox,

Recommended Posts

Hey Fella's,

A little confuzzled here.

On the try icon I can only perform 'Settings' once. i.e I click Settings-><enter input>->Click save-><output message box appears>->Close MsgBox->Close GUI. If I try the sequence again I cannot get the Settings GUI to reappear, nor can I exit.

I did some debugging and it seems I am stuck in the second While loop, even if I add ExitLoop to the GUI_EVENT_CLOSE case

Any advice to make this work while calling the GUI from within a function? What schoolboy error am I making?

Cheers

Byron

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;; Various options
AutoItSetOption ("TrayIconDebug", 1)
AutoItSetOption ("TrayMenuMode",1)
AutoItSetOption ("MustDeclareVars",0)

$settings = TrayCreateItem("Settings")
$exit   = TrayCreateItem("Exit")

While 1    
   Switch TrayGetMsg()

      Case $settings
         Settings()
      Case $exit
         Exit

   EndSwitch

WEnd

Func Settings()
   
   GUICreate("Settings", 231, 229, 321, 495) 
   $input = GUICtrlCreateInput("", 75, 135, 145, 21)
   $save = GUICtrlCreateButton("Save", 71, 195, 73, 25)
   GUISetState(@SW_SHOW)
   
   While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            GUIDelete()
         Case $save
            MsgBox(0,"Output",GUICtrlRead($input))
      EndSwitch
   WEnd
EndFunc
Edited by byronsmith
Link to comment
Share on other sites

  • Solution

Hi,
Well that's simple, when you close the settings GUI you don't Exit your subloop so it continues looping.

...
Func Settings()
 
   GUICreate("Settings", 231, 229, 321, 495)
   $input = GUICtrlCreateInput("", 75, 135, 145, 21)
   $save = GUICtrlCreateButton("Save", 71, 195, 73, 25)
   GUISetState(@SW_SHOW)
 
   While 1
      Switch GUIGetMsg()
         Case $GUI_EVENT_CLOSE
            GUIDelete()
            ExitLoop ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
         Case $save
            MsgBox(0,"Output",GUICtrlRead($input))
      EndSwitch
   WEnd
EndFunc

_
Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Well I'll be...

I'm fairly certain I tried that obvious solution, even mention it in my OP! My sincerest apologies for wasting your time and many many thanks for taking the time to reply. I really do appreciate it.

All the best.

Actually, whilst I'm here and as you've been so kind as to answer my question, would you mind showing me how to remove the 'tick' next to the tray menu options? When I select settings there is a tick?

Edited by byronsmith
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...