Jump to content
Sign in to follow this  
Achilles

Weird Problem

Recommended Posts

Achilles

Alright, this is an actual replication of a problem I'm having, I can't get it to show the message box! Here's the code:

#noTrayIcon 
#include <GuiConstants.au3>

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

Local $firstGUI, $secondGUI

Local $successess = 0

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() 
    $secondGUI = GuiCreate('B', 125, 145, -1, -1, $DS_SETFOREGROUND) 
        GuiSetOnEvent($GUI_EVENT_CLOSE, '_CloseTwo') 
    
    GuiCtrlCreateButton('Test Two', 10, 10, 100, 100) 
        GuiCtrlSetOnEvent(-1, '_NewestTest')
        
    $successess = 0
    
    GuiSetState()
    
    While $successess = 0 
        Sleep(250) 
        ConsoleWrite(' |OTHER LOOP| ')
        $count += 1
        If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
    WEnd
    
    Msgbox(0, 'Yay', 'We are finsihed!');  <----- GOAL IS TO GET HERE
    Exit
EndFunc

Func _NewestTest() 
    Msgbox(0, '', 'Success')
    GuiDelete($secondGUI)
    $successess += 1 ;  <----- THIS SHOULD ALLOW US TO GET TO OUR GOAL
EndFunc

Func _Close() 
    GuiDelete($firstGUI) 
EndFunc

Func _CloseTwo() 
    GuiDelete($secondGUI) 
EndFUnc

Func _Exit() 
    Exit 
EndFunc

How to win the Smiley:

If you can modify this code so that I can see the message box my pressing the button on the GUI "B" you win the smiley!

Requirements and rules:

- There must be a tray icon, two GUI's

- The tray must trigger the first GUI which must trigger the second GUI

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
GreenHouse

#noTrayIcon 
#include <GuiConstants.au3>

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

Local $firstGUI, $secondGUI

Local $successess = 0

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() 
    $secondGUI = GuiCreate('B', 125, 145, -1, -1, $DS_SETFOREGROUND) 
        GuiSetOnEvent($GUI_EVENT_CLOSE, '_CloseTwo') 
    
    GuiCtrlCreateButton('Test Two', 10, 10, 100, 100) 
        GuiCtrlSetOnEvent(-1, '_NewestTest')
        
    $successess    = 0
    
    GuiSetState()
EndFunc

    While $successess = 0 
        Sleep(250) 
        ConsoleWrite(' |OTHER LOOP| ')
        $count += 1
        If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
    WEnd
    
    Msgbox(0, 'Yay', 'We are finsihed!');  <----- GOAL IS TO GET HERE
    Exit
;EndFunc

Func _NewestTest() 
    Msgbox(0, '', 'Success')
    GuiDelete($secondGUI)
    $successess += 1 ;  <----- THIS SHOULD ALLOW US TO GET TO OUR GOAL
EndFunc

Func _Close() 
    GuiDelete($firstGUI) 
EndFunc

Func _CloseTwo() 
    GuiDelete($secondGUI) 
EndFUnc

Func _Exit() 
    Exit 
EndFunc

Do I get a smily now? :)

- Pas

Share this post


Link to post
Share on other sites
Achilles

;code

Do I get a smily now? :)

- Pas

No, that isn't what I want. I want that one message box "Msgbox(0, 'Yay', 'We are finished') to appear, and it should appear as part of the _NewTest() function.

<insert lack of smiley> No smiley for you!


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
Fossil Rock

I modified your code a bit, let me know if this will work for you.

#noTrayIcon
#include <GuiConstants.au3>

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

Local $firstGUI, $secondGUI

Local $successess = 0

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()
    $secondGUI = GuiCreate('B', 125, 145, -1, -1, $DS_SETFOREGROUND)
        GuiSetOnEvent($GUI_EVENT_CLOSE, '_CloseTwo')
    
    GuiCtrlCreateButton('Test Two', 10, 10, 100, 100)
        GuiCtrlSetOnEvent(-1, '_NewestTest')
        
    $successess = 0
    
    GuiSetState()
    
EndFunc

Func _NewestTest()
    Msgbox(0, '', 'Success')
    GuiDelete($secondGUI)
    $successess += 1 ;  <----- THIS SHOULD ALLOW US TO GET TO OUR GOAL
    If $successess <> 0 Then _Finished()
EndFunc

Func _Finished()
    While $successess = 0
        Sleep(250)
        ConsoleWrite(' |OTHER LOOP| ')
        $count += 1
        If Mod($count, 8) = 0 then ConsoleWrite(@CRLF)
    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

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
Achilles

I modified your code a bit, let me know if this will work for you.

;code
Alright I give up on this problem. What you did could help me solve the problem but I found a much easier solution. What my original code had was a button that brought up a GUI that gave you an option to choose between two different things but on that GUI I wasn't getting any response. So, I've decided to just make two different buttons, it will look better two because all my buttons are custom made and the GUI that I made wasn't so this way I'll have more of my program in my style GUI.

Anyways, thanks for the help...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
Fossil Rock

Alright I give up on this problem. What you did could help me solve the problem but I found a much easier solution. What my original code had was a button that brought up a GUI that gave you an option to choose between two different things but on that GUI I wasn't getting any response. So, I've decided to just make two different buttons, it will look better two because all my buttons are custom made and the GUI that I made wasn't so this way I'll have more of my program in my style GUI.

Anyways, thanks for the help...

So do I get the smiley or not? :)

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.