DigDeep Posted January 5, 2016 Share Posted January 5, 2016 Hi,Can someone please help here...When I enter any text in the Input box 1 and Select the Button 1 within Form1, it should open the Form2 containing InputBox2 and Button 2.Can we get multiple forms built inside each other? #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 578, 120, 700, 421) $Button1 = GUICtrlCreateButton("Button1", 360, 48, 75, 25) $Input1 = GUICtrlCreateInput("Input1", 40, 48, 257, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 415, 123, 789, 423) $Button1 = GUICtrlCreateButton("Button2", 288, 48, 75, 25) $Input2 = GUICtrlCreateInput("Input2", 40, 48, 217, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;~ Pressing the Button 1 should open the $FORM2 and complete actions EndSwitch WEnd Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 In the wiki you'll find a tutorial on how to cope with multiple GUIs: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
topten Posted January 5, 2016 Share Posted January 5, 2016 Here you are#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 578, 120, 700, 421) $Button1 = GUICtrlCreateButton("Button1", 360, 48, 75, 25) $Input1 = GUICtrlCreateInput("Input1", 40, 48, 257, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 415, 123, 789, 423) $Button1 = GUICtrlCreateButton("Button2", 288, 48, 75, 25) $Input2 = GUICtrlCreateInput("Input2", 40, 48, 217, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ Pressing the Button 1 should open the $FORM2 and complete actions EndSwitch WEnd DigDeep 1 Link to comment Share on other sites More sharing options...
InunoTaishou Posted January 5, 2016 Share Posted January 5, 2016 You want forms inside of forms? Of course we can do that!expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $frmMain = GUICreate("Main GUI", 768, 480, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CLIPCHILDREN)) Global $inpMainInput = GUICtrlCreateInput("Input1", 10, 10, 100, 20) Global $btnMainButton = GUICtrlCreateButton("Button1", 120, 10, 100, 20) Global $aButtons[1][1] Global $aInputs[1][1] GUICtrlSetResizing($inpMainInput, $GUI_DOCKALL) GUICtrlSetResizing($btnMainButton, $GUI_DOCKALL) GUISetState(@SW_SHOW, $frmMain) While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[1] Case $frmMain Switch $nMsg[0] Case $GUI_EVENT_CLOSE Exit Case $btnMainButton Local $frmChild = GUICreate("Form inside form : Count " & UBound($aButtons, $UBOUND_ROWS) - 1, 480, 256, -20, 30, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX)) Local $inpChildInput = GUICtrlCreateInput("Input2", 10, 10, 200, 20) Local $btnChildButton = GUICtrlCreateButton("Button2", 220, 10, 100, 20) GUICtrlSetResizing($inpChildInput, $GUI_DOCKALL) GUICtrlSetResizing($btnChildButton, $GUI_DOCKALL) $aButtons[UBound($aButtons, $UBOUND_ROWS) - 1][0] = $btnChildButton $aInputs[UBound($aInputs, $UBOUND_ROWS) - 1][0] = $inpChildInput ReDim $aButtons[UBound($aButtons, $UBOUND_ROWS) + 1][1] ReDim $aInputs[UBound($aInputs, $UBOUND_ROWS) + 1][1] _WinAPI_SetParent($frmChild, $frmMain) GUISetState(@SW_SHOW, $frmChild) EndSwitch Case Else Switch $nMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($nMsg[1]) Case Else For $i = 0 to UBound($aButtons, $UBOUND_ROWS) - 1 If ($nMsg[0] = $aButtons[$i][0]) Then GUICtrlSetData($aInputs[$i][0], "Button ID " & $aButtons[$i][0] & " for form " & $i & " pressed") ExitLoop EndIf Next EndSwitch EndSwitch WEnd Link to comment Share on other sites More sharing options...
DigDeep Posted January 5, 2016 Author Share Posted January 5, 2016 Thank you topten and all. Link to comment Share on other sites More sharing options...
Milas Posted January 28, 2016 Share Posted January 28, 2016 you could also put the second gui in a function you created and call the function. i find that to make the program in general more organized and easier to follow $Form1 = GUICreate("Form1", 578, 120, 700, 421) $Button1 = GUICtrlCreateButton("Button1", 360, 48, 75, 25) $Input1 = GUICtrlCreateInput("Input1", 40, 48, 257, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _secondGUI() endswitch func _sencondGUI() $Form2 = GUICreate("Form1", 415, 123, 789, 423) $Button1 = GUICtrlCreateButton("Button2", 288, 48, 75, 25) $Input2 = GUICtrlCreateInput("Input2", 40, 48, 217, 24) GUISetState(@SW_SHOW) endfunc Link to comment Share on other sites More sharing options...
AutoBert Posted January 28, 2016 Share Posted January 28, 2016 It's not a good practice to create forms in the 'GuiGetMsgLoop' so everytime the Msg ic catched a new form is created. I do this like this: 2GUI.au3 nearly the same as in: On 05.01.2016 at 7:49 AM, water said: In the wiki you'll find a tutorial on how to cope with multiple GUIs: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs 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