i2i8 Posted February 20, 2021 Share Posted February 20, 2021 (edited) expandcollapse popupOpt("GUIOnEventMode", 1) #include "sUDF\MetroGUI_UDF.au3" #include "sUDF\_GUIDisable.au3" #include <Array.au3> _Metro_EnableHighDPIScaling() _SetTheme("DarkMidnightBlue") WndMain() While 1 Sleep(5) WEnd ;#FUNCTION# ================================================================================================================================== Func WndMain() Global $wMain = 1280 Global $hMain = 768 Global $hWndMain = _Metro_CreateGUI("Main", $wMain, $hMain, -1, -1, True) Global $aWinGetPos_Main = WinGetPos($hWndMain) GUISetState() ChildForm() Global $WndMain_Control = _Metro_AddControlButtons(True, False, True, False, True) Global $GUI_CLOSE_BUTTON = $WndMain_Control[0] Global $GUI_MAXIMIZE_BUTTON = $WndMain_Control[1] Global $GUI_RESTORE_BUTTON = $WndMain_Control[2] Global $GUI_MINIMIZE_BUTTON = $WndMain_Control[3] Global $GUI_FULLSCREEN_BUTTON = $WndMain_Control[4] Global $GUI_FSRestore_BUTTON = $WndMain_Control[5] Global $GUI_MENU_BUTTON = $WndMain_Control[6] GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvent_WndMain") GUICtrlSetOnEvent($GUI_CLOSE_BUTTON, "_GUIEvent_WndMain") GUICtrlSetOnEvent($GUI_MAXIMIZE_BUTTON, "_GUIEvent_WndMain") GUICtrlSetOnEvent($GUI_MINIMIZE_BUTTON, "_GUIEvent_WndMain") GUICtrlSetOnEvent($GUI_RESTORE_BUTTON, "_GUIEvent_WndMain") GUICtrlSetOnEvent($GUI_MENU_BUTTON, "_GUIEvent_WndMain") EndFunc ;==>MainForm Func ChildForm() _ArrayDisplay($aWinGetPos_Main, "") ;error: aWinGetPos_Main(): undefined function. ;Global $hChildForm = GUICreate("", $aWinGetPos_Main[2], $aWinGetPos_Main[3], aWinGetPos_Main[0], aWinGetPos_Main[1], $WS_POPUP, $WS_EX_MDICHILD, $hWndMain) Global $hChildForm = GUICreate("", 800, 600, 100, 50, $WS_POPUP, $WS_EX_MDICHILD, $hWndMain) GUISetState() EndFunc ;==>ChildForm Func _GUIEvent_WndMain() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON _Metro_GUIDelete($hWndMain) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! Exit Case $GUI_MAXIMIZE_BUTTON GUISetState(@SW_MAXIMIZE, $hWndMain) Case $GUI_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE, $hWndMain) Case $GUI_RESTORE_BUTTON GUISetState(@SW_RESTORE, $hWndMain) Case $GUI_MENU_BUTTON ;Create an Array containing menu button names Local $MenuButtonsArray[5] = ["General", "Settings", "About", "Contact", "Exit"] ; Open the metro Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_MenuStart($hWndMain, 150, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ChildForm() Case "1" ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF) Case "2" ConsoleWrite("Returned 2 = About button clicked." & @CRLF) Case "3" ConsoleWrite("Returned 3 = Contact button clicked." & @CRLF) Case "4" ConsoleWrite("Returned 4 = Exit button clicked." & @CRLF) _Metro_GUIDelete($hWndMain) Exit EndSwitch EndSwitch EndFunc ;==>_GUIEvent_WndMain As shown in the above code, I want to use separate Menu bars for childForm and mainForm respectively. In the current situation, the Menu bar for mainForm (Menu, Minimize, Close, etc.) has been moved to childForm. Please help me. Thank you very much... The effect of the above code implementation is as follows: The effect I want to achieve is as follows: PS: MetroGUI UDF v5.1 Edited February 20, 2021 by i2i8 Link to comment Share on other sites More sharing options...
i2i8 Posted February 20, 2021 Author Share Posted February 20, 2021 in ChildForm, I use the following Global $hChildForm = GUICreate("", $aWinGetPos_Main[2], $aWinGetPos_Main[3], aWinGetPos_Main[0], aWinGetPos_Main[1], $WS_POPUP, $WS_EX_MDICHILD, $hWndMain) The error is as follows: ;error: aWinGetPos_Main(): undefined function. Why? Link to comment Share on other sites More sharing options...
i2i8 Posted February 25, 2021 Author Share Posted February 25, 2021 who can help... Link to comment Share on other sites More sharing options...
pixelsearch Posted February 25, 2021 Share Posted February 25, 2021 (edited) Concerning the error, a couple of $ are missing (line below intentionally pasted to bold both $ signs) Global $hChildForm = GUICreate("", $aWinGetPos_Main[2], $aWinGetPos_Main[3], $aWinGetPos_Main[0], $aWinGetPos_Main[1], $WS_POPUP, $WS_EX_MDICHILD, $hWndMain) Edited February 25, 2021 by pixelsearch Link to comment Share on other sites More sharing options...
pixelsearch Posted February 25, 2021 Share Posted February 25, 2021 On 2/20/2021 at 4:52 AM, i2i8 said: In the current situation, the Menu bar for mainForm (Menu, Minimize, Close, etc.) has been moved to childForm. Please help me. Thank you very much... Just move your ChildForm() line at the very end of Func WndMain() Because the way it is placed now, all buttons are created in the child form, not in the main GUI ! After that, it should be easy for you to add a close button in the child form (as you already did in the main GUI). Also the example found in the zip file contains a function to create a 2nd GUI Good luck FrancescoDiMuro 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