Sign in to follow this  
Followers 0
buymeapc

Control Position Not Correct After Window Sizing

3 posts in this topic

#1 ·  Posted

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

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

You might have a look at GUICtrlSetResizing  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

I found some issues with my manual resizing in my main script, but this was key in fixing the issue. Thanks mikell!!

Share this post


Link to post
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
Sign in to follow this  
Followers 0