Logman Posted March 24, 2008 Share Posted March 24, 2008 How to set desired width x height GUI in WinMove() function? I need exact dimensions both dialogs (smaller and bigger) after resizing. Thanks Following code doesn't work: expandcollapse popup#include <GuiConstants.au3> $L_Width = 475 ; Less $L_Height = 430 ; Less $M_Width = 700 ; More $M_Height = 600 ; More $MAIN_GUI = GUICreate("MAIN", $L_Width, $L_Height) $BTN_CLOSE = GUICtrlCreateButton("&Close", 344, 390, 115, 25, 0) $BTN_MORE = GUICtrlCreateButton("&More...", 16, 390, 115, 25, 0) $LBL_NFO1 = GUICtrlCreateLabel($L_Width & " x " & $L_Height & " >> Desired width x height", 16, 16, 300, 17) $GuiPos = WinGetClientSize($MAIN_GUI) $LBL_NFO2 = GUICtrlCreateLabel($GuiPos[0] & " x " & $GuiPos[1] & " >> Real width x height", 16, 36, 300, 17) GUISetState(@SW_SHOW, $MAIN_GUI) While 1 $tMsg = GUIGetMsg() Select Case $tMsg = $GUI_EVENT_CLOSE Or $tMsg = $BTN_CLOSE ExitLoop Case $tMsg = $BTN_MORE If GUICtrlRead($BTN_MORE) = "&More..." Then $BtnText = "&Less..." $Width = $M_Width $Height = $M_Height Else $BtnText = "&More..." $Width = $L_Width $Height = $L_Height EndIf GUICtrlSetData ($BTN_MORE, $BtnText) WinMove($MAIN_GUI,"", (@DesktopWidth/2)-($Width/2), (@DesktopHeight/2)-($Height/2), $Width, $Height) $GuiPos = WinGetClientSize($MAIN_GUI) GUICtrlSetData ($LBL_NFO1, $Width & " x " & $Height & " >> Desired width x height") GUICtrlSetData ($LBL_NFO2, $GuiPos[0] & " x " & $GuiPos[1] & " >> Real width x height") Case Else EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
-Ultima- Posted March 24, 2008 Share Posted March 24, 2008 (edited) expandcollapse popup#include <GuiConstants.au3> $L_Width = 475 ; Less $L_Height = 430 ; Less $M_Width = 700 ; More $M_Height = 600 ; More $MAIN_GUI = GUICreate("MAIN", $L_Width, $L_Height) $BTN_CLOSE = GUICtrlCreateButton("&Close", 344, 390, 115, 25, 0) $BTN_MORE = GUICtrlCreateButton("&More...", 16, 390, 115, 25, 0) $LBL_NFO1 = GUICtrlCreateLabel($L_Width & " x " & $L_Height & " >> Desired width x height", 16, 16, 300, 17) $GuiPos = WinGetClientSize($MAIN_GUI) $LBL_NFO2 = GUICtrlCreateLabel($GuiPos[0] & " x " & $GuiPos[1] & " >> Real width x height", 16, 36, 300, 17) GUISetState(@SW_SHOW, $MAIN_GUI) ;===== $GuiBorder = WinGetPos($MAIN_GUI) $GuiBorder[2] -= $GuiPos[0] $GuiBorder[3] -= $GuiPos[1] ;===== While 1 $tMsg = GUIGetMsg() Select Case $tMsg = $GUI_EVENT_CLOSE Or $tMsg = $BTN_CLOSE ExitLoop Case $tMsg = $BTN_MORE If GUICtrlRead($BTN_MORE) = "&More..." Then $BtnText = "&Less..." $Width = $M_Width $Height = $M_Height Else $BtnText = "&More..." $Width = $L_Width $Height = $L_Height EndIf GUICtrlSetData ($BTN_MORE, $BtnText) ;===== WinMove($MAIN_GUI,"", (@DesktopWidth/2)-($Width/2), (@DesktopHeight/2)-($Height/2), $Width + $GuiBorder[2], $Height + $GuiBorder[3]) ;===== $GuiPos = WinGetClientSize($MAIN_GUI) GUICtrlSetData ($LBL_NFO1, $Width & " x " & $Height & " >> Desired width x height") GUICtrlSetData ($LBL_NFO2, $GuiPos[0] & " x " & $GuiPos[1] & " >> Real width x height") Case Else EndSelect WEnd Exit Explanation: WinMove() changes the window's size, window decorations (titlebar, borders, etc) included. You need to compensate for the decorations when using WinMove() if you want to keep the client size the same. Edited March 24, 2008 by -Ultima- [ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ] Link to comment Share on other sites More sharing options...
Logman Posted March 25, 2008 Author Share Posted March 25, 2008 Explanation: WinMove() changes the window's size, window decorations (titlebar, borders, etc) included. You need to compensate for the decorations when using WinMove() if you want to keep the client size the same.Many Thanks, -Ultima-! 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