Jump to content

Problem With A GUI


Recommended Posts

Your problem isn't about GUI anyway, it's a general logic question.

If execution is inside of a custom endless loop, other code won't be executed.

And in a loop like this

While $successess = 0 
        Sleep(250) 
        ConsoleWrite(' |OTHER LOOP| ')
        $count += 1
        If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
    WEndoÝ÷ Ùìz_¢»azk ¶­ël¥«,yÛh
ì¢W®+^J!ÉƧßÛbµ·¬¢g­)à)¶¬jëh×6While 1 
    Sleep(250) 
    ConsoleWrite($msg)
    $count += 1
    If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
WEnd

And modify the global variable $msg when you need to (in place of that While $successess = 0 loop).

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Possible solution here Post #4.

Siao is correct, that loop locked her down and wouldn't let go..

Yep, and I 'm the stubborn newbie that just didn't want to give up on getting that smiley... Oh well... It's about 4 in the morning here but I have sort of a solution if you really need to do it the way you had it set up.

Like the guys said, It's an infinite loop and has no way of getting its infinite but kicked.... unlesss... (and it's probably not advised but) you switch back and forth between OnEventModes.

Probably you should really use one or the other but I guess I got it to work they way you wanted your code to by switching form OnEventMode 1 back to 0.

here's the code:

#noTrayIcon 
#include <GuiConstants.au3>

Opt("TrayOnEventMode", 1)
Opt("GUIOnEventMode", 1) 
Opt("TrayMenuMode", 1)

Local $firstGUI, $secondGUI

Local $count

TrayCreateItem('Test') 
    TrayItemSetOnEvent(-1, '_Test') 

TrayCreateItem('') 

TrayCreateItem('Exit')
    TrayItemSetOnEvent(-1, '_Exit')

TraySetState()

While 1 
    Sleep(250) 
    ConsoleWrite(' |MAIN LOOP| ')
    $count += 1
    If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
WEnd

Func _Test() 
    $firstGUI = GuiCreate('A', 125, 145, -1, -1, $DS_SETFOREGROUND) 
        GuiSetOnEvent($GUI_EVENT_CLOSE, '_Close') 

    GuiCtrlCreateButton('Test', 10, 10, 100, 100) 
        GuiCtrlSetOnEvent(-1, '_NewTest') 
        
    GuiSetState()
EndFunc 

Func _NewTest() 
    Opt("GUIOnEventMode", 0) 
    
    $secondGUI = GuiCreate('B', 125, 145, -1, -1, $DS_SETFOREGROUND) 
        GuiSetOnEvent($GUI_EVENT_CLOSE, '_CloseTwo') 
    
    GuiCtrlCreateButton('Test Two', 10, 10, 100, 100)
    
    GuiSetState()
    
        While 1
        Sleep(250)
        ConsoleWrite(' |OTHER LOOP| ')
        $count += 1
        If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
        $GUIGetmsg = GUIGetMsg()
        If $GUIGetmsg > 0 Then
                ExitLoop
                EndIf
        WEnd
    
    Msgbox(0, 'Yay', 'We are finsihed!');  <----- GOAL IS TO GET HERE
    Exit
EndFunc

Func _Close() 
    GuiDelete($firstGUI) 
EndFunc

Func _CloseTwo() 
    GuiDelete($secondGUI) 
EndFUnc

Func _Exit() 
    Exit 
EndFunc

cheers, I'm hitting the sack.

- Pas :)

Edited by GreenHouse
Link to comment
Share on other sites

Alright, I give up. See here.

@GreenHouse: That would work except I forgot to mention I need to keep it all with GuiOnEvent mode...

@Siao: My actual code where I'm getting this problem has different loops... Anyways, it doesn't matter!

@Everyone: Thanks for the help

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...