Jump to content

OnEvent - Two GUI, second one ... inactive


 Share

Recommended Posts

Hi guys, this time I want to make an easy example:

#include <GUIConstants.au3>

Opt("GuiOnEventMode",1)

$Main=GUICreate ( 'Main Window', 90, 135, -1, -1, $WS_MINIMIZEBOX ) 
$close=GUICtrlCreateButton ( 'Close', 3, 90, 113, 18 )
$history=GUICtrlCreateButton ( 'History', 3, 73, 113, 18)
    
GUICtrlSetOnEvent($Close, 'quit')   
GUICtrlSetOnEvent($history, 'History')

While 1         
    GuiSetState(@SW_SHOW)
Wend

;~ ;;FUNCTIONS-----------------------------------------------------------
Func quit()
    Exit 0
EndFunc

Func History()
    $Histo=GUICreate ( 'Secondary Window', 300, 150, -1, -1,$WS_MINIMIZEBOX, $WS_EX_TOPMOST  )
    $CloseHis=GUICtrlCreateButton ( 'Cancel', 5, 105, 285, 18 )
    
GUICtrlSetOnEvent($CloseHis, 'quit')
    While 1
        GUISetState ( @SW_SHOW, $Histo)
        Sleep(50)
    Wend

And an Easy question: Why the "GUICtrlSetOnEvent($CloseHis, 'quit')" in the Second UI isn't working?

Thanks a lot

Edited by eHrgo
Sorry for my Bad English.
Link to comment
Share on other sites

Can't break 'inturupts' within 'inturupts' with gui events...

http://www.autoitscript.com/forum/index.php?showtopic=28292

http://www.autoitscript.com/forum/index.php?showtopic=42375

One of the more annoying factors of the feature IMO...

you'll want-

#include <GUIConstants.au3>

Opt("GuiOnEventMode",1)

$Main=GUICreate ( 'Main Window', 90, 135, -1, -1, $WS_MINIMIZEBOX ) 
$close=GUICtrlCreateButton ( 'Close', 3, 90, 113, 18 )
$history=GUICtrlCreateButton ( 'History', 3, 73, 113, 18)
    
GUICtrlSetOnEvent($Close, 'quit')   
GUICtrlSetOnEvent($history, 'History')
GuiSetState(@SW_SHOW)
While 1         
    Sleep(1000)
Wend

;~ ;;FUNCTIONS-----------------------------------------------------------
Func quit()
    Exit 0
EndFunc

Func History()
    $Histo=GUICreate ( 'Secondary Window', 300, 150, -1, -1,$WS_MINIMIZEBOX, $WS_EX_TOPMOST  )
    $CloseHis=GUICtrlCreateButton ( 'Cancel', 5, 105, 285, 18 )
    GUICtrlSetOnEvent($CloseHis, 'quit')
    GUISetState ( @SW_SHOW, $Histo)
EndFunc
Link to comment
Share on other sites

Try this:

#include <GUIConstants.au3>

Opt("GuiOnEventMode",1)

$Main=GUICreate ( 'Main Window', 90, 135, -1, -1, $WS_MINIMIZEBOX ) 
$close=GUICtrlCreateButton ( 'Close', 3, 90, 113, 18 )
$history=GUICtrlCreateButton ( 'History', 3, 73, 113, 18)
    
GUICtrlSetOnEvent($Close, 'quit')   
GUICtrlSetOnEvent($history, 'History')
GuiSetState(@SW_SHOW)

While 1         
    Sleep(1000)
Wend

;~ ;;FUNCTIONS-----------------------------------------------------------
Func quit()
    Exit 0
EndFunc

Func History()
    Global $Histo=GUICreate ( 'Secondary Window', 300, 150, -1, -1,$WS_MINIMIZEBOX, $WS_EX_TOPMOST  )
    $CloseHis=GUICtrlCreateButton ( 'Cancel', 5, 105, 285, 18 )
    GUICtrlSetOnEvent($CloseHis, 'quit2')
    GUISetState ( @SW_SHOW, $Histo)
EndFunc

Func quit2()
    GUIDelete($Histo)
EndFunc
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...