legend Posted February 24, 2016 Share Posted February 24, 2016 Any help would be much appreciated, I'm trying to make a button spawn a new gui, and when i click the X on the new gui, the first gui should still work fine. but it's not that easy expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MetroGUI_UDF.au3> ;Set Theme _SetTheme("DarkTeal") ;See MetroThemes.au3 for selectable themes or to add more ;Create resizable Metro GUI $Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True, True); Returns an array, see below how to use it: ;Set a variable name for the Hover-Reg Array that contains all the needed data for the hover effects. You will be needing this for almost every action. Name it wisely. $GUI_HOVER_REG = $Form1[1] ;Set variables for the handles of the GUI-Control buttons (Close/Maximize/Restore/Minimize) $GUI_CLOSE_BUTTON = $Form1[2] $GUI_MAXIMIZE_BUTTON = $Form1[3] $GUI_RESTORE_BUTTON = $Form1[4] $GUI_MINIMIZE_BUTTON = $Form1[5] ;Set GUI/Form handle from the _Metro_CreateGUI return array. $Form1 = $Form1[0] $Button1 = _Metro_CreateButton($GUI_HOVER_REG, "Button1", 24, 16, 161, 57) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 _Metro_HoverCheck_Loop($GUI_HOVER_REG, $Form1);This hover check has to be added to the main While loop, otherwise the hover effects won't work. $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON Exit Case $GUI_MAXIMIZE_BUTTON GUISetState(@SW_MAXIMIZE) Case $GUI_RESTORE_BUTTON GUISetState(@SW_RESTORE) Case $GUI_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE) case $Button1 newgui() EndSwitch WEnd func newgui() #Region ### START Koda GUI section ### Form= $test = _Metro_CreateGUI("test", 242, 55, -1, -1, True, True) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 _Metro_HoverCheck_Loop($GUI_HOVER_REG, $test) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON GUICtrlDelete($test) EndSwitch WEnd EndFunc Here's the UDF: Right now, I can't click the X on the new GUI ($test) I want it to delete it, when you click the x, and the old gui ($form1) should still work Link to comment Share on other sites More sharing options...
AutoBert Posted February 24, 2016 Share Posted February 24, 2016 Change to: func newgui() #Region ### START Koda GUI section ### Form= $test = _Metro_CreateGUI("test", 242, 55, -1, -1, True, True) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 _Metro_HoverCheck_Loop($GUI_HOVER_REG, $test) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON GUICtrlDelete($test) ExitLoop EndSwitch WEnd EndFunc then your first Gui will work after closing new Gui. Better use GuiGetMsg with Parameter: expandcollapse popup#include <GUIConstantsEx.au3> #include<WindowsConstants.au3> Global $hGui1, $hGui2 = -99, $idMsgBox, $idZurueck, $idbtnExit2 ;_CreateGui2() ;entweder hier oder erst wenn benötigt ($idbtmToGui2 Klick) #Region GUI1 ##################################################################################### $hGui1 = GUICreate('GUI 1', 400, 280, 140, 150, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) ;erzeugt eine GUI , das zurückgebebene Handle wird in der Variablen $hGui1 gespeichert ;die GUI hat BOXen für Mininmieren, Maximieren und ist in der Größe frei änderbar $idbtnToGui2 = GUICtrlCreateButton('&Aufruf GUI 2', 20, 20, 100, 21) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) ;verankert den Button "Aufruf Gui 2" links und oben und fixiert die Größe ;beim Resizen bleibt es dadurch auf seiner Position am rechten Rand $idbtnICQ = GUICtrlCreateButton('&ICQ', 20, 50, 100, 21) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKLEFT + $GUI_DOCKTOP) ;verankert den Button "ICQ" links und oben und fixiert die Größe ;beim Resizen bleibt es dadurch auf seiner Position am rechten Rand $idbtnExit1 = GUICtrlCreateButton('be&enden', 280, 225, 100, 21) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM) ;verankert den Button "beenden" links und oben und fixiert die Größe ;beim Resizen bleibt es dadurch auf seiner Position am rechten Rand GUISetState(@SW_SHOW, $hGui1) #EndRegion ########################################################################################### While 1 $nMsg = GUIGetMsg(1) ;extended Modus wichtig!! Switch $nMsg[1] ;für welches Fenster ist die Message Case $hGui1 ;ab hier ist Gui 1 dran Switch $nMsg[0] ;welche Message wurde ausgelöst Case $idbtnToGui2 GUISetState(@SW_DISABLE, $hGui1) ;Gui 1 gegen Benutzereingaben sperren If $hGui2 = -99 Then _CreateGui2() ;nur wenn nicht am Anfang bereits erzeugt nötig, dann auf Vorbelegung der Variable in Global achten) GUISetState(@SW_SHOW, $hGui2) ;Gui 2 anzeigen Case $idbtnICQ MsgBox(0, "", "Jetzt würde ICQ gestartet", 0, $hGui1) ;Run("C:\Program Files\ICQ7.0\ICQ.exe") Case $idbtnExit1, $GUI_EVENT_CLOSE _end() EndSwitch Case $hGui2 ;ab hier ist Gui 2 dran Switch $nMsg[0] ;welche Message wurde ausgelöst Case $idMsgBox MsgBox(0, 'Test', 'Test', 0, $hGui2) Case $idZurueck, $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $hGui1) ;Gui 1 wieder entsperren GUISetState(@SW_HIDE, $hGui2) ;Gui 2 verstecken Case $idbtnExit2 _end() EndSwitch EndSwitch WEnd Func _CreateGui2() $hGui2 = GUICreate('GUI 2', 400, 280, 200, 50, -1, -1, $hGui1) ;wichtig ist der letzte Parameter ;erzeugt eine GUI als Child von Gui1, das zurückgebebene Handle wird in der Variablen $hGui2 gespeichert $idMsgBox = GUICtrlCreateButton('&MsgBox', 20, 20, 100, 21) $idZurueck = GUICtrlCreateButton('&Zurück zu GUI 1', 20, 50, 100, 21) $idbtnExit2 = GUICtrlCreateButton('be&enden', 280, 250, 100, 21) GUISetState(@SW_HIDE, $hGui2) ;Gui 2 vorerst verstecken EndFunc ;==>_CreateGui2 Func _end() GUIDelete($hGui2) GUIDelete($hGui1) Exit EndFunc ;==>_end Link to comment Share on other sites More sharing options...
afeen Posted February 27, 2016 Share Posted February 27, 2016 Legend , I looking for help about that, but helper said : sheet man, Impossible if 2 UDF work together. ( helper not really help me :-D hahaha) Link to comment Share on other sites More sharing options...
AutoBert Posted February 27, 2016 Share Posted February 27, 2016 (edited) That's not nice, first snipet helps and second shows the way to make it better. You only have to adapt the logic specialy GuiGetMsg(1). But i think you haven't tested 1. snipet. Edited February 27, 2016 by AutoBert Link to comment Share on other sites More sharing options...
afeen Posted February 29, 2016 Share Posted February 29, 2016 Once Inspirational quotes from AutoBert, Last night, I start to retrying, retricking , reModing and converting .au3 to .exe ...itz be like ExampleGUI.exe 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