Jump to content

Control Position Not Correct After Window Sizing


Recommended Posts

I have a GUI that has a few controls on it and when I double-click on the window edge to maximize it in either direction, like if I double-click the top edge of the GUI, it maximizes vertically, but the width remains the same. Some controls move accordingly with the window resizing, but others do not. In my repro, I just have a simple button control that has a TOP setting as 188. When I double-click the top edge of the GUI, on my screen, the control moves to 380 even though I want it to remain at 188. How can I prevent the control from moving and keep it at the setting of 188?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $g__iButtonPos = 188; <<<<<<<<<<< Where I want the control to remain

$hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
$idButton = GUICtrlCreateButton("Test", 200, $g__iButtonPos, 100, 20)

GUISetState(@SW_SHOW, $hGUI)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    $aPos = ControlGetPos($hGUI, "", $idButton)
    If $aPos[1] <> $g__iButtonPos Then
        ConsoleWrite("!> WRONG: This is not equal to $g__iButtonPos: " & $aPos[1] & @CRLF)
    Else
        ConsoleWrite("+> CORRECT: This is equal to $g__iButtonPos: " & $aPos[1] & @CRLF)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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