Jump to content
Sign in to follow this  
byronsmith

GUI/Forms and While Loops

Recommended Posts

byronsmith

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

Share this post


Link to post
Share on other sites
FireFox

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
byronsmith

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

Share this post


Link to post
Share on other sites
byronsmith

Nevermind :) TrayMenuMode :) Thanks again.

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  

×