ludocus Posted September 7, 2008 Share Posted September 7, 2008 (edited) When I click the maximize button, my gui automaticly resizes to @DesktopWidth and @DesktopHeight is it possible to make it only resize to like, 300 width and 400 height? because I cant figure out how.. I knoew how to make it maximize to my own size, but then the maximize button does not get replaced bye the restore button.. Edited September 7, 2008 by ludocus Link to comment Share on other sites More sharing options...
martin Posted September 7, 2008 Share Posted September 7, 2008 (edited) When I click the maximize button, my gui automaticly resizes to @DesktopWidth and @DesktopHeight is it possible to make it only resize to like, 300 width and 400 height? because I cant figure out how.. This 'maximises' to some maximum and prevents you resizing beyond the max size by dragging. (Or below the minimum size.) #include <GUIConstantsEx.au3> #include <windowsconstants.au3> Opt("GUIEventOptions", 1);<-----------------important ;Const $WM_GETMINMAXINFO = 0x24 Global $maxht = 600, $maxwid = 600, $minht = 100, $minwid = 100;<-------size limits $gui = GUICreate("Test GUI", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO");stops resizing beyond limits Global $wp = wingetpos($gui) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_MAXIMIZE;<--deals with clicking the maximize button WinMove($gui, "", $wp[0], $wp[1], $maxwid, $maxht) EndSwitch WEnd Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam) $wp = WinGetPos($gui) ConsoleWrite($wp[0] & ', ' & $wp[1] & @CRLF) $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $minwid); min X DllStructSetData($minmaxinfo, 8, $minht); min Y DllStructSetData($minmaxinfo, 9, $maxwid + 1); max X DllStructSetData($minmaxinfo, 10, $maxht + 1); max Y Return 0 EndFunc ;==>MY_WM_GETMINMAXINFO The disadvantage of this is that you don't get the maximize button changing to a restore button. I don't know how to fix that. EDIT:changed declaration of $wp so the first time window maximized it behaves the same as other times. Edited September 7, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
baghenamoth Posted September 7, 2008 Share Posted September 7, 2008 When I click the maximize button, my gui automaticly resizes to @DesktopWidth and @DesktopHeight is it possible to make it only resize to like, 300 width and 400 height? because I cant figure out how.. there's things to fix : - when window is minimized and you click on it in taskbar then height and width change to DesktopHeight and @DesktopWidth - when maximized, it's still possible to move it... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $v_msg,$h_ButtonQuit,$h_myGui Local $n_MaxWidth = @DesktopWidth*2/3 Local $n_MaxHeight = @DesktopHeight*2/3 $h_myGui = GUICreate("Test maximize",200,50,-1,-1, $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU +$WS_MAXIMIZEBOX) $h_ButtonQuit = GUICtrlCreateButton("&Quit", 10, 10,80,30) GUISetState() While 1 $v_msg = GUIGetMsg() Select Case $v_msg = $GUI_EVENT_CLOSE ExitLoop Case $v_msg = $h_ButtonQuit ExitLoop Case $v_msg = $GUI_EVENT_MAXIMIZE WinMove($h_myGui,"",0,0,$n_MaxWidth,$n_MaxHeight) EndSelect WEnd Link to comment Share on other sites More sharing options...
ludocus Posted September 7, 2008 Author Share Posted September 7, 2008 ok, thats how far I got by myself to.. but when it is maximized, the maximize button does not change into a restore size button.. how do I do that? Link to comment Share on other sites More sharing options...
martin Posted September 7, 2008 Share Posted September 7, 2008 ok, thats how far I got by myself to.. but when it is maximized, the maximize button does not change into a restore size button.. how do I do that?This is far from perfect but it demonstrates an idea which works. expandcollapse popup#include <GUIConstantsEx.au3> #include <windowsconstants.au3> Opt("GUIEventOptions", 1);<-----------------important Const $SPI_SETWORKAREA = 47, $SPI_GETWORKAREA = 48 Const $SPIF_SENDCHANGE = 11 $newWid = @DesktopWidth - 300 $newHt = @DesktopHeight $DtopRect = DllStructCreate("int[4]") $PDTopRect = DllStructGetPtr($DtopRect) $OrigRect = DllStructCreate("int[4]") $POrigRect = DllStructGetPtr($OrigRect) $gui = GUICreate("Example amximize to small size", 300, 300, 400, 400,BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MAXIMIZE $last = wingetpos($gui) $res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETWORKAREA, "int", 0, "ptr", $POrigRect, "int", 0) DllStructSetData($DtopRect, 1, 300, 1);top DllStructSetData($DtopRect, 1, 300, 2);left DllStructSetData($DtopRect, 1, 700, 3);bottom DllStructSetData($DtopRect, 1, 700, 4);right $res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETWORKAREA, "int", 0, "ptr", $PDTopRect, "int", $SPIF_SENDCHANGE) WinSetState($gui, "", @SW_MAXIMIZE) $res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETWORKAREA, "int", 0, "ptr", $POrigRect, "int", $SPIF_SENDCHANGE) Winmove($gui,"",300,301) case $GUI_EVENT_RESTORE winmove($gui,"",$last[0],$last[1],$last[2],$last[3]) winsetstate($gui,"",@SW_RESTORE) EndSwitch WEnd Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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