TryingToCode Posted January 25, 2023 Posted January 25, 2023 I'm struggling with 2 GUIs where one opens the other.ย The first GUI successfully opens the second but then I can't get the second GUI to respond to any events or button presses.ย Please could someone help identify what am I missing? Here is some example code to illustrate my problem. expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Example() Func Example() Global $hFirstGUI = GUICreate("First GUI", 330, 120) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI") Local $idNewGUI = GUICtrlCreateButton("New GUI", 10, 90, 85, 25) GUICtrlSetOnEvent(-1, "NewGUI") Local $idOK = GUICtrlCreateButton("OK", 240, 90, 85, 25) GUICtrlSetOnEvent(-1, "CloseGUI") GUISetState(@SW_SHOW, $hFirstGUI) While 1 Sleep(100) WEnd EndFunc Func CloseGUI() GUIDelete($hFirstGUI) Exit EndFunc Func NewGUI() GUIDelete($hFirstGUI) Global $hSecondGUI = GUICreate("Second GUI") GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI2",$hSecondGUI) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) GUICtrlSetOnEvent($idOK, "CloseGUI2") GUISetState(@SW_SHOW, $hSecondGUI) While 1 Sleep(100) WEnd EndFunc Func CloseGUI2() GUIDelete($hSecondGUI) Exit EndFunc I'm using Opt("GUIOnEventMode", 1) because this is required elsewhere in my code.
SOLVE-SMART Posted January 25, 2023 Posted January 25, 2023 Hi @TryingToCode, this should be helpful:ย managing-multiple-guis ๐ . Best regards Sven Stay innovative! Spoiler ๐ย Au3Forums ๐ฒ AutoIt (en) Cheat Sheet ๐ AutoIt limits/defaults ๐ Code Katas: [...] (comming soon) ๐ญ Collection of GitHub users with AutoIt projects ๐ย False-Positives ๐ฎย Me on GitHub ๐ฌย Opinion about new forum sub category ๐ย UDF wiki list โย VSCode-AutoItSnippets ๐ย WebDriver FAQs ๐จโ๐ซย WebDriver Tutorial (coming soon)
Solution TryingToCode Posted January 25, 2023 Author Solution Posted January 25, 2023 Thanks, the answer was that I needed to delete the following lines from my NewGUI function.ย They are only needed in the first GUI. While 1 Sleep(100) WEnd ย SOLVE-SMART 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now