Jump to content

Nested On Event Mode


Coldburn
 Share

Recommended Posts

I'm making a template to use for future fun and at the same time trying to wrap my mind around nested GUI's. The problem I'm having is the 2nd window seems to lock up. I've specified the parent window handle on the 2nd and 3rd GUI's but doesn't resolve the whole lock up issue. What is the preferred method for doing something like this? - Thanks!

#include <GUIConstants.au3>

Opt('TrayIconDebug', 1  )     ; 0=no info, 1=debug line info
Opt('GUIOnEventMode', 1 )   ; gui - on event mode

Global $GUI1 = ''
Global $GUI2 = ''
Global $GUI3 = ''

; Start GUI
GUI_1()

While 1
    Sleep(100)
WEnd

Exit

;***
;* Start of functions
;*

Func GUI_1()
    $GUI1_Title  = 'The First GUI'
    $GUI1_Height = 200
    $GUI1_Left   = 200
    $GUI1_Top    = 200
    $GUI1_Width  = 200
    
    GUICreate($GUI1_Title, $GUI1_Width, $GUI1_Height, $GUI1_Left, $GUI1_Top)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'GUI_Close')
    
    $GUI1_Btn1 = GUICtrlCreateButton('GUI_2', 10, ($GUI1_Height-35), 70, 25)    ; left, top, width, height
    GUICtrlSetOnEvent($GUI1_Btn1, 'GUI_2')
    
    GUISetState(@SW_SHOW)
    
EndFunc

Func GUI_2()
    $GUI2_Title  = 'The Second GUI'
    $GUI2_Height = 200
    $GUI2_Left   = 300
    $GUI2_Top    = 300
    $GUI2_Width  = 200
    $GUI2_Style  = -1
    $GUI2_ExStyle = -1
    
    If Not WinExists($GUI2_Title) Then
        GUICreate($GUI2_Title, $GUI2_Width, $GUI2_Height, $GUI2_Left, $GUI2_Top, $GUI2_Style, $GUI2_ExStyle, $GUI1)
        GUISetOnEvent($GUI_EVENT_CLOSE, 'GUI_Delete')
        
        $GUI2_Btn2 = GUICtrlCreateButton('GUI_3', 10, ($GUI2_Height-35), 70, 25)    ; left, top, width, height
        GUICtrlSetOnEvent($GUI2_Btn2, 'GUI_3')
        
        GUISetState(@SW_SHOW)
        
    EndIf
    
EndFunc

Func GUI_3()
    $GUI3_Title  = 'The Third GUI'
    $GUI3_Height = 200
    $GUI3_Left   = 400
    $GUI3_Top    = 400
    $GUI3_Width  = 200
    $GUI3_Style  = -1
    $GUI3_ExStyle = -1
    
    If Not WinExists($GUI3_Title) Then
        GUICreate($GUI3_Title, $GUI3_Width, $GUI3_Height, $GUI3_Left, $GUI3_Top, $GUI3_Style, $GUI3_ExStyle, $GUI2)
        GUISetOnEvent($GUI_EVENT_CLOSE, 'GUI_Delete')
        
        GUISetState(@SW_SHOW)
        
    EndIf
    
EndFunc

Func GUI_Delete()
    GUIDelete()
    
EndFunc

Func GUI_Close()
    Exit
    
EndFunc
Edited by Coldburn
Link to comment
Share on other sites

Func GUI_Delete()
    GUIDelete(@GUI_WinHandle)  ;gotta tell it which gui to delete
   
EndFunc
oÝ÷ Ùçbµø±yÛZÏêº^aæ¡"Øhºm¶­¶ºØ­)e±©eߧv,y÷Þrدz¤Yba{h橧}Ó+"³Z´ZvÚâyÖÞ~Þ",µçb+bjYr"­¶¬jg}÷µ«­¢+Ø)Õ¹U%}
±½Í ¤(%MÝ¥Ñ U%}]¥¹!¹±($%
ÍÀÌØíU$È($$%U%±Ñ¡U%}]¥¹!¹±¤($$%U%MÑMÑÑ¡M]}M!=°ÀÌØíU$Ĥ($$$($%
ÍÀÌØíU$Ì($$%U%±Ñ¡U%}]¥¹!¹±¤($$%U%MÑMÑÑ¡M]}M!=°ÀÌØíU$Ȥ($$$($%
ͱÍ($$%á¥Ð($$$(%¹MÝ¥Ñ ($$)¹Õ¹(
Link to comment
Share on other sites

you have globalized these correctly

Global $GUI1 = ''

Global $GUI2 = ''

Global $GUI3 = ''

... but when you create the GUI's you do not use the Global handle

you use

GUICreate($GUI1_Titl,,,,,,,,,,

you should be using

$GUI1 = GUICreate($GUI1_Titl.....

to use you code above.... GUISetState(@SW_SHOW, $GUI1)

8)

NEWHeader1.png

Link to comment
Share on other sites

you have globalized these correctly

Global $GUI1 = ''

Global $GUI2 = ''

Global $GUI3 = ''

... but when you create the GUI's you do not use the Global handle

you use

GUICreate($GUI1_Titl,,,,,,,,,,

you should be using

$GUI1 = GUICreate($GUI1_Titl.....

to use you code above.... GUISetState(@SW_SHOW, $GUI1)

8)

Yea! That's it! I knew I was forgetting something somewhere! - Thank you!

Link to comment
Share on other sites

When I added in @GUI_WinHandle, your gui 2 and gui 3 could be closed individually, and if you closed gui 1, it closed them all. Is this not expected behavior?

Expected but not working. Valuater found that I wasn't assigning the handles to GuiCreate() functions, but thanks for your help!

Edited by Coldburn
Link to comment
Share on other sites

Heh no problem... very strange though. When all I did was add in the gui_winhandle, it worked perfectly.

edit - Or did you want closing gui 3 to close gui 2 with it? That, it didn't do with winhandle alone. But it did unfreeze 2 and allow it to close on its own, after 3 had been opened.

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