IchBistTod Posted March 5, 2011 Share Posted March 5, 2011 I have a gui that can be resized but I want the gui to not be able to go under its original size. Like how do I stop from resizing smaller than a certain size? [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
smartee Posted March 5, 2011 Share Posted March 5, 2011 this is a quick mockup of one approach GUISetOnEvent($GUI_EVENT_RESIZED, "_reSize", $myGUI) Func _reSize() $minW = 500 $minH = 200 $myGuiInfo = WinGetPos($myGUI) If ($myGuiInfo[2] < $minW) Or ($myGuiInfo[3] < $minH) Then WinMove($myGUI, "", $myGuiInfo[0], $myGuiInfo[1], $minW, $minH) EndIf EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 IchBistTod, Easy when you know how! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 300, $GUIMINHT = 100 ; set your restrictions here Global $GUIMAXWID = 800, $GUIMAXHT = 500 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $aPos = WinGetPos($hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID) ; max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Chimaera Posted March 5, 2011 Share Posted March 5, 2011 (edited) I tried something a little different but im curious Melba23 I did this from your code #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 516, $GUIMINHT = 538 ; set your restrictions here Global $GUIMAXWID = 516, $GUIMAXHT = 538 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $aPos = WinGetPos($hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID) ; max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO This bit Global $GUIMINWID = 516, $GUIMINHT = 538 ; set your restrictions here Global $GUIMAXWID = 516, $GUIMAXHT = 538 It was odd i had to do more then 500 on each to get it to lock the window so its moveable but it dosent change size when you touch it? can you explain why? Or is there an easier way? Chimaera Edited March 5, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 Chimaera,When you create the GUI the size coordinates refer to the "client area" - the bit inside the borders. When you use the WM_GETMINMAXINFO struct, the coordinates refer to the whole GUI - including the borders. So you need to make the struct sizes slightly bigger that the initial GUI if you do not want a jump in size when you first try to resize. I hope this script makes it clearer - resise the "Test" GUI and you will see that it fits neatly inside the client area of the "Sizer" GUI: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 200, $GUIMINHT = 200 ; set your restrictions here Global $GUIMAXWID = 200, $GUIMAXHT = 200 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 200, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $hGUI_2 = GUICreate("Sizer", 200, 200, 100, 100) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID) ; max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFODoes that explain it clearly enough? As to making a GUI immoveable, you just need to intercept the $SC_MOVE message like this:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Const $SC_MOVE = 0xF010 $hGUI_Move = GUICreate("Movable GUI", 500, 500, 100, 100) GUISetState() $hGUI_Static = GUICreate("Immovable GUI", 500, 500, 200, 200) GUISetState() GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If $hWnd = $hGUI_Static Then If BitAND($wParam, 0x0000FFF0) = $SC_MOVE Then Return False EndIf Return $GUI_RUNDEFMSG EndFuncAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Chimaera Posted March 5, 2011 Share Posted March 5, 2011 Aah thanks for the lesson o mighty one This is what i wanted a simple Gui that cannot be streched but can be moved #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Const $SC_MOVE = 0xF010 $hGUI_Move = GUICreate("Movable GUI", 500, 500) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Many thanks Melba23 If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 Chimaera,o mighty oneNot at all - just been around a bit longer. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Bowmore Posted March 5, 2011 Share Posted March 5, 2011 Thanks for the lesson M23. I wish I had learned this years ago. I've been using wingetpos() and winmove() in my ignorance. It's a truth that you never stop learning. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook 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