Jump to content

Recommended Posts

Posted

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.

1.png.199e2fce9725f41827b0ed12ba8fda76.png

 

2.png.843248d9453689d1063a0f9aea4b4562.png

 

 

; 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

 

Posted

Hey 

i would try to redraw your gui like

; 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...

; 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  :graduated:

i will take a look on it later :P 

regards

why do i get garbage when i buy garbage bags? <_<

Posted (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  :graduated:

i will take a look on it later :P 

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 by TanerJames

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...