TanerJames Posted December 7, 2020 Share Posted December 7, 2020 Hi, my example code for three child gui. (WS_EX_MDICHILD) No problem but when I change the screen resolution while the application is running (not closing), all mdi childs gui are a problem. (Alignment changes) How can I fix this problem? Thanks. expandcollapse popup; Include files #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; Autoit Options Opt("GUIOnEventMode", 1) ; GUI variables $mainGUI = Null $topGUI = Null $rightGUI = Null $leftGUI = Null ; Initialize GUI guiInit() While 1 Sleep(10) WEnd Func guiInit() ; Create Main GUI $mainGUI = GUICreate("Main Window", 600, 600) ; Child GUI for top row $topGUI = GUICreate("", 600, 50, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) GUISetBkColor(0x0000FF, $topGUI) ; Child GUI for left side ; contains row labels and fields $leftGUI = GUICreate("", 300, 550, 0, 50, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) $cButton = GUICtrlCreateButton("Test", 50, 50, 80, 30) GUICtrlSetOnEvent($cButton, "_Test") GUISetBkColor(0x00FF00, $leftGUI) ; Child GUI for right side $rightGUI = GUICreate("", 300, 550, 300, 50, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) GUISetBkColor(0xFF0000, $rightGUI) ; Main GUI events GUISetOnEvent($GUI_EVENT_CLOSE, "close", $mainGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $topGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $leftGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $rightGUI) ; Show GUIs GUISetState(@SW_SHOW, $topGUI) GUISetState(@SW_SHOW, $leftGUI) GUISetState(@SW_SHOW, $rightGUI) GUISetState(@SW_SHOW, $mainGUI) GUIRegisterMsg( $WM_NCACTIVATE, "_WM_NCACTIVATE") EndFunc ;==>guiInit Func _Test() MsgBox($MB_SYSTEMMODAL, "Hi", "Pressed") EndFunc ;==>_Test Func close() Exit EndFunc ;==>close Func _WM_NCACTIVATE( $hWnd, $iMsg, $wParam, $lParam) If $hWnd = $mainGUI Then If Not $wParam Then Return 1 EndIf Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
Aelc Posted December 8, 2020 Share Posted December 8, 2020 Hey i would try to redraw your gui like expandcollapse popup; Include files #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; Autoit Options Opt("GUIOnEventMode", 1) ; GUI variables $mainGUI = Null $topGUI = Null $rightGUI = Null $leftGUI = Null Global $width = @DesktopWidth Global $height = @DesktopHeight ; Initialize GUI guiInit() While 1 If @DesktopWidth <> $width Or @desktopheight <> $height Then _Redraw() Sleep(10) WEnd Func _Redraw() GUIDelete ($mainGUI) GUIDelete ($leftGUI) GUIDelete ($rightGUI) GUIDelete ($topGUI) guiInit() $width = @DesktopWidth $height = @DesktopHeight EndFunc Func guiInit() ; Create Main GUI $mainGUI = GUICreate("Main Window", 600, 600) ; Child GUI for top row $topGUI = GUICreate("", 600, 50, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) GUISetBkColor(0x0000FF, $topGUI) ; Child GUI for left side ; contains row labels and fields $leftGUI = GUICreate("", 300, 550, 0, 50, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) $cButton = GUICtrlCreateButton("Test", 50, 50, 80, 30) GUICtrlSetOnEvent($cButton, "_Test") GUISetBkColor(0x00FF00, $leftGUI) ; Child GUI for right side $rightGUI = GUICreate("", 300, 550, 300, 50, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) GUISetBkColor(0xFF0000, $rightGUI) ; Main GUI events GUISetOnEvent($GUI_EVENT_CLOSE, "close", $mainGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $topGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $leftGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $rightGUI) ; Show GUIs GUISetState(@SW_SHOW, $topGUI) GUISetState(@SW_SHOW, $leftGUI) GUISetState(@SW_SHOW, $rightGUI) GUISetState(@SW_SHOW, $mainGUI) GUIRegisterMsg( $WM_NCACTIVATE, "_WM_NCACTIVATE") EndFunc ;==>guiInit Func _Test() MsgBox($MB_SYSTEMMODAL, "Hi", "Pressed") EndFunc ;==>_Test Func close() Exit EndFunc ;==>close Func _WM_NCACTIVATE( $hWnd, $iMsg, $wParam, $lParam) If $hWnd = $mainGUI Then If Not $wParam Then Return 1 EndIf Return $GUI_RUNDEFMSG EndFunc but i don't know what you are trying to do ... in this case the window would be always redrawn in center of the screen... normally it would be moved by the change of resolution. you also could do a workaround with winmove... but it's a bit more complicated i would say... especially if you want to work with more MDI child GUIs inside because you would have to adjust them one by one... expandcollapse popup; Include files #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; Autoit Options Opt("GUIOnEventMode", 1) ; GUI variables $mainGUI = Null $topGUI = Null $rightGUI = Null $leftGUI = Null Global $width = @DesktopWidth Global $height = @DesktopHeight ; Initialize GUI guiInit() While 1 If @DesktopWidth <> $width Or @desktopheight <> $height Then _Redraw() Sleep(10) WEnd Func _Redraw() Local $aPos = WinGetPos ( $mainGUI ) If IsArray ($aPos) Then WinMove ( $topGUI,"",$aPos[0]+7,$aPos[1]+29,$aPos[2]-14,$aPos[3]/12 ) WinMove ( $leftGUI,"",$aPos[0]+7,$aPos[1] + $aPos[3]/12+29,$aPos[2]/2-7,$aPos[3]/1.09-35 ) WinMove ( $rightGUI,"",$aPos[0]+$aPos[2]/2,$aPos[1] + $aPos[3]/12+29,$aPos[2]/2-7,$aPos[3]/1.09-35 ) $width = @DesktopWidth $height = @DesktopHeight EndIf EndFunc Func guiInit() ; Create Main GUI $mainGUI = GUICreate("Main Window", 600, 600,-1,-1,-1,$WS_EX_OVERLAPPEDWINDOW) ; Child GUI for top row $topGUI = GUICreate("", 600, 50, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) GUISetBkColor(0x0000FF, $topGUI) ; Child GUI for left side ; contains row labels and fields $leftGUI = GUICreate("", 300, 550, 0, 50, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) $cButton = GUICtrlCreateButton("Test", 50, 50, 80, 30) GUICtrlSetOnEvent($cButton, "_Test") GUISetBkColor(0x00FF00, $leftGUI) ; Child GUI for right side $rightGUI = GUICreate("", 300, 550, 300, 50, $WS_POPUP, $WS_EX_MDICHILD, $mainGUI) GUISetBkColor(0xFF0000, $rightGUI) $cResize = GUICtrlCreateButton("Resize", 50, 50, 80, 30) GUICtrlSetOnEvent($cResize, "_Redraw") ; Main GUI events GUISetOnEvent($GUI_EVENT_CLOSE, "close", $mainGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $topGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $leftGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $rightGUI) ; Show GUIs GUISetState(@SW_SHOW, $topGUI) GUISetState(@SW_SHOW, $leftGUI) GUISetState(@SW_SHOW, $rightGUI) GUISetState(@SW_SHOW, $mainGUI) GUIRegisterMsg( $WM_NCACTIVATE, "_WM_NCACTIVATE") EndFunc ;==>guiInit Func _Test() MsgBox($MB_SYSTEMMODAL, "Hi", "Pressed") EndFunc ;==>_Test Func close() Exit EndFunc ;==>close Func _WM_NCACTIVATE( $hWnd, $iMsg, $wParam, $lParam) If $hWnd = $mainGUI Then If Not $wParam Then Return 1 EndIf Return $GUI_RUNDEFMSG EndFunc but by the way why do you have to change the resolution while the script is running? I just took a fast look on it, but i could bet there is another better solution with winapi i will take a look on it later regards why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
TanerJames Posted December 9, 2020 Author Share Posted December 9, 2020 (edited) 22 hours ago, Aelc said: expandcollapsepopup but by the way why do you have to change the resolution while the script is running? I just took a fast look on it, but i could bet there is another better solution with winapi i will take a look on it later regards Thank you for your help. I have another GUI. While this application is running, windows update install VGA drivers and change the resolution. My GUI is broken Is this problem due to autoit? or is it windows? is a bug? Like you said maybe there is an API for that. Thanks. Edited December 9, 2020 by TanerJames 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