TryingToCode Posted January 25, 2023 Share 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. Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted January 25, 2023 Share 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) Link to comment Share on other sites More sharing options...
Solution TryingToCode Posted January 25, 2023 Author Solution Share 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 Link to comment Share on other sites More sharing options...
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