Sign in to follow this  
Followers 0

Button Not Working - Child Windows, GUIOnEventMode


7 posts in this topic

Posted (edited)

I have the following code: I cannot get the last button in the third GUI to do anything. Can a NEW pair of eys check it out and see what I did wrong?

#include <GUIConstantsEx.au3>

Global $_GuiAir, $_Button666, $bPassed = False, $_GuiName

Example()

Func Example()
Opt("GUIOnEventMode", 1)

GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

GUICtrlCreateButton("New Gui", 10, 60, 50)
GUICtrlSetOnEvent(-1, "_Air")

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
WEnd

EndFunc ;==>Example

Func _Air()
$_GuiAir = GUICreate('Air Call')
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
$_Button666 = GUICtrlCreateButton('TestIT', 0, 0)
GUICtrlSetOnEvent($_Button666, "__AirCall")

GUISetState(@SW_SHOW, $_GuiAir)
EndFunc ;==>_Air

Func __AirCall()
Switch @GUI_CtrlId
Case $_Button666
;MsgBox('', '', 'pop')
Name('name')
If $bPassed Then
GUISetState(@SW_HIDE, $_GuiName)
GUIDelete($_GuiName)

GUISetState(@SW_HIDE, $_GuiAir)
GUIDelete($_GuiAir)
$bPassed = False
EndIf

EndSwitch
EndFunc ;==>__AirCall

Func Name($sName)
Local $font = "Comic Sans MS"
$sAnswer = $sName

$_GuiName = GUICreate('Air Check' & $sName, 400, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

;GUICtrlCreateLabel($sName, 50, 5, 200, 50)
;GUICtrlSetFont(-1, 20, 400, 1, $font)

;$_InputCheck = GUICtrlCreateInput('', 50, 100, 200, 50)
;GUICtrlSetFont(-1, 20, 400, 1, $font)

$_ButtonCheck = GUICtrlCreateButton('CHECK', 20, 150, 50, 30)
GUISetOnEvent($_ButtonCheck, 'test')

GUISetState(@SW_HIDE, $_GuiAir)
GUIDelete($_GuiAir)

GUISetState(@SW_SHOW, $_GuiName)
EndFunc ;==>Name


Func test()

MsgBox('', '', 'button pressed')
EndFunc ;==>test

Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Exit

Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

Case @GUI_CtrlId = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

EndSelect
EndFunc ;==>SpecialEvents
Edited by nitekram

Share this post


Link to post
Share on other sites



Posted

Which one is the third GUI and which button, just so I don't have to start counting GUI functions.

Share this post


Link to post
Share on other sites

Posted

$_GuiName is the third gui - in the function Name()

Share this post


Link to post
Share on other sites

Posted

Change the second line:

$_ButtonCheck = GUICtrlCreateButton('CHECK', 20, 150, 50, 30)
GUICtrlSetOnEvent($_ButtonCheck, 'test') ; <<<<<<<<<<<<<<<<< Change it to this

Share this post


Link to post
Share on other sites

Posted

I feel stupid - thanks

Share this post


Link to post
Share on other sites

Posted

No need to feel stupid, sometimes Scite's "intellisense" gives you options and we don't pay close enough attention. Happens to me all of the time.

Share this post


Link to post
Share on other sites

Posted (edited)

$_ButtonCheck = GUICtrlCreateButton('CHECK', 20, 150, 50, 30)
GUICtrlSetOnEvent(-1, "Buttontest") ; or you can do it like this, this way you wont get confused with a bunch of variable names

Edited by Cid

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  
Followers 0