aa2zz6 Posted September 1, 2020 Share Posted September 1, 2020 (edited) Can anyone help me figure out how to resize child GUI's and parent GUI at the same time? In a previous project I was able to use _WM_SIZE() function to do so but that was with a single child GUI and the browser adjusted quite well. Right now it's not working with anything. Any help would be much appreciated! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIEx.au3> Global $hGUI_Width = @DesktopWidth / 2 + 400 Global $hGUI_Height = @DesktopHeight / 2 + 200 Global $hGUI_Child_Webapp, $hGUI_Child_Workforce, $hGUI_Child_Dashboard, $hGUI_Main = GUICreate("Project Management Tracking", $hGUI_Width + 15, $hGUI_Height + 90,-1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX)) Opt("WinTitleMatchMode", 2) ; Alters the method that is used to match window titles during search operations. GUICtrlCreateGroup("App Manager", 6, 2, 230 - 15, 75) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUICtrlCreateLabel(" Web Map", 10, 54, 60, 15) GUICtrlSetBkColor(-1, 0xFFCCCC) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) GUICtrlCreateLabel(" Field Work ", 80, 54, 60, 15) GUICtrlSetBkColor(-1, 0xFFCCCC) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) GUICtrlCreateLabel(" Dashboard ", 150, 54, 60, 15) GUICtrlSetBkColor(-1, 0xFFCCCC) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE) $btnWebapp = IconButton("NEO Facilities", 20, 13, 45, 45, 30, @ScriptDir & "\img\NEO_LOGO.ico") $btnWorkforce = IconButton("Workforce", 90, 13, 45, 45, 30, @ScriptDir & "\img\workforce.ico") $btnDashboard = IconButton("Dashboard", 160, 13, 45, 45, 30, @ScriptDir & "\img\operations-dashboard.ico") _Create_Child($hGUI_Main) GUISetState(@SW_SHOW, $hGUI_Main) ;~ GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") GUISetState(@SW_SHOW, $hGUI_Child_Webapp) GUIRegisterMsg($WM_SIZE, "_WM_SIZE") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit GUISetState(@SW_SHOW, $hGUI_Child_Webapp) Case $btnWebapp GUISetState(@SW_SHOW, $hGUI_Child_Webapp) GUISetState(@SW_HIDE, $hGUI_Child_Workforce) GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) Case $btnWorkforce GUISetState(@SW_HIDE, $hGUI_Child_Webapp) GUISetState(@SW_SHOW, $hGUI_Child_Workforce) GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) Case $btnDashboard GUISetState(@SW_HIDE, $hGUI_Child_Webapp) GUISetState(@SW_HIDE, $hGUI_Child_Workforce) GUISetState(@SW_SHOW, $hGUI_Child_Dashboard) EndSwitch WEnd ;====================================== Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconSize, $BIDLL, $BIconNum = -1) GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - $BIconSize) / 2), $BIconSize, $BIconSize) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DISABLE) $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS) Return $XS_btnx EndFunc ;==>IconButton ;====================================== Func _Create_Child($hGUI_Main) Local $aGUI_Main_Pos = WinGetPos($hGUI_Main), $lnCount = @DesktopHeight ;==>_Create_Child $hGUI_Child_Webapp = GUICreate("", $hGUI_Width, $hGUI_Height, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER), $WS_EX_MDICHILD, $hGUI_Main) ;GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") ;Local $text = GUICtrlCreateLabel("Dashboard", 10, 10, 380, ($lnCount * 20) - 20) WinMove($hGUI_Child_Webapp, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110) ;===========================>_Webapp Chrome ShellExecute("chrome.exe", "https://egas.maps.arcgis.com/apps/webappviewer/index.html?id=e749ca4f26ff4b69b090ff548f042baf --new-window --start-minimized") $hPrivate = WinWaitActive("[REGEXPTITLE:(?i)(.*'Google Chrome')]", "", 1) WinSetState($hPrivate, "", @SW_HIDE) $Nhandle = WinGetHandle("Google Chrome") _WinAPI_SetParent($Nhandle, $hGUI_Child_Webapp) _WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) $aPos = ControlGetPos($hGUI_Child_Webapp, "", $hPrivate) WinMove($Nhandle, "", $aPos[0] - 10, $aPos[1] - 110, $aPos[2] + 18, $aPos[3] + 118) ;==>_Create_Child $hGUI_Child_Workforce = GUICreate("", $hGUI_Width, $hGUI_Height, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER), $WS_EX_MDICHILD, $hGUI_Main) ;GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") ;Local $text = GUICtrlCreateLabel("Dashboard", 10, 10, 380, ($lnCount * 20) - 20) WinMove($hGUI_Child_Workforce, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110) ;===========================>_Webapp Chrome ShellExecute("chrome.exe", "https://workforce.arcgis.com/projects/e8f8bcebaf2945b5a871d66697fbc451/dispatch/assignments --new-window --start-minimized") $hPrivate = WinWaitActive("[REGEXPTITLE:(?i)(.*'Google Chrome')]", "", 1) WinSetState($hPrivate, "", @SW_HIDE) $Nhandle = WinGetHandle("Google Chrome") _WinAPI_SetParent($Nhandle, $hGUI_Child_Workforce) _WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) $aPos = ControlGetPos($hGUI_Child_Workforce, "", $hPrivate) WinMove($Nhandle, "", $aPos[0] - 10, $aPos[1] - 110, $aPos[2] + 18, $aPos[3] + 118) ;==>_Create_Child $hGUI_Child_Dashboard = GUICreate("", $hGUI_Width, $hGUI_Height, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER), $WS_EX_MDICHILD, $hGUI_Main) ;GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") ;Local $text = GUICtrlCreateLabel("Dashboard", 10, 10, 380, ($lnCount * 20) - 20) WinMove($hGUI_Child_Dashboard, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110) ;===========================>_Webapp Chrome ShellExecute("chrome.exe", "https://egas.maps.arcgis.com/apps/opsdashboard/index.html#/f9ad3cb50b2d495eb267201f36ae1567 --new-window --start-minimized") $hPrivate = WinWaitActive("[REGEXPTITLE:(?i)(.*'Google Chrome')]", "", 1) WinSetState($hPrivate, "", @SW_HIDE) $Nhandle = WinGetHandle("Google Chrome") _WinAPI_SetParent($Nhandle, $hGUI_Child_Dashboard) _WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) $aPos = ControlGetPos($hGUI_Child_Dashboard, "", $hPrivate) WinMove($Nhandle, "", $aPos[0] - 10, $aPos[1] - 110, $aPos[2] + 18, $aPos[3] + 118) EndFunc ;==>_Create_Child ;====================================== Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; Resize child GUI to parent GUI Local $aGUI_Main_Pos = WinGetPos($hGUI_Main), $lnCount = @DesktopHeight WinMove($hGUI_Child_Webapp, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110) WinMove($hGUI_Child_Workforce, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110) WinMove($hGUI_Child_Dashboard, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110) EndFunc Webapp.zip Edited September 1, 2020 by aa2zz6 Included folder with script and button images Link to comment Share on other sites More sharing options...
Dan_555 Posted September 1, 2020 Share Posted September 1, 2020 (edited) The winmove function has a resize option. Try this change in the _WM_SIZE function: WinMove($hGUI_Child_Webapp, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110, $aGUI_Main_Pos[2]-50, $aGUI_Main_Pos[3]-120) It resizes the one window when the main window is resized. Edited September 1, 2020 by Dan_555 aa2zz6 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
aa2zz6 Posted September 2, 2020 Author Share Posted September 2, 2020 (edited) Thanks!! @Dan_555 It's awesome building a web GUI that resizes both the child GUI's and browsers! Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; Resize child GUI to parent GUI Local $aGUI_Main_Pos = WinGetPos($hGUI_Main), $lnCount = @DesktopHeight WinMove($hGUI_Child_Webapp, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110, $aGUI_Main_Pos[2] - 50, $aGUI_Main_Pos[3] - 120) WinMove($hGUI_Child_Workforce, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110, $aGUI_Main_Pos[2] - 50, $aGUI_Main_Pos[3] - 120) WinMove($hGUI_Child_Dashboard, "", $aGUI_Main_Pos[0] + 10, $aGUI_Main_Pos[1] + 110, $aGUI_Main_Pos[2] - 50, $aGUI_Main_Pos[3] - 120) ; Get label posiition and size and adjust child GUI to fit $aPos = ControlGetPos($hGUI_Main, "", $hGUI_Child_Webapp) WinMove($Nhandle, "", $aPos[0] - 10, $aPos[1] - 110, $aPos[2] + 18, $aPos[3] + 118) $aPos = ControlGetPos($hGUI_Main, "", $hGUI_Child_Workforce) WinMove($Nhandle1, "", $aPos[0] - 10, $aPos[1] - 110, $aPos[2] + 18, $aPos[3] + 118) $aPos = ControlGetPos($hGUI_Main, "", $hGUI_Child_Dashboard) WinMove($Nhandle2, "", $aPos[0] - 10, $aPos[1] - 110, $aPos[2] + 18, $aPos[3] + 118) EndFunc ;==>_WM_SIZE Edited September 2, 2020 by aa2zz6 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