BoonPek Posted October 21, 2011 Posted October 21, 2011 (edited) Hello there! Currently, I use this from Melba23 to prevent my AutoIt GUI from being resized too small, and it works extremely well! #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_GETMINMAXINFO Problem with this, though, is that it doesn't seem to work with external, non AutoIt-created GUIs. To compensate for this, I created a simple script that loops continuously and checks that the window size is large enough. If not, it would resize the window accordingly: Global $p_ID, $hWnd, $hSize $p_ID = Run('Notepad.exe') $hWnd = WinWait('[CLASS:Notepad]', '', 5) While WinGetProcess($hWnd) <> $p_ID $hWnd = WinList("[CLASS:Notepad]") For $i = 1 To $hWnd[0][0] If WinGetProcess($hWnd[$i][0]) = $p_ID Then $hWnd = $hWnd[$i][1] ExitLoop EndIf Next WEnd While WinExists($hWnd) $hSize = WinGetPos($hWnd) If $hSize[2] < 800 Then WinMove($hWnd, '', $hSize[0], $hSize[1], 800, $hSize[3]) If $hSize[3] < 600 Then WinMove($hWnd, '', $hSize[0], $hSize[1], $hSize[2], 600) WEnd Cheap, I know, but I am unable to find any other alternatives. Thanks for any input, guys! Edited October 21, 2011 by BoonPek
guinness Posted October 23, 2011 Posted October 23, 2011 I think your second solution is a good workaround. #include <WinAPIEx.au3> ; Search the Examples forum. Global $aArray, $hHandle, $iPID $iPID = Run('Notepad.exe') $aArray = _WinAPI_EnumProcessWindows($iPID) If @error Then Exit EndIf $hHandle = $aArray[1][0] While 1 If ProcessExists($iPID) = 0 Then ExitLoop EndIf $aArray = WinGetPos($hHandle) If $aArray[2] < 800 Then WinMove($hHandle, '', $aArray[0], $aArray[1], 800, $aArray[3]) EndIf If $aArray[3] < 600 Then WinMove($hHandle, '', $aArray[0], $aArray[1], $aArray[2], 600) EndIf Sleep(100) ; Reduce CPU. WEnd UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
BoonPek Posted October 24, 2011 Author Posted October 24, 2011 I think your second solution is a good workaround. #include <WinAPIEx.au3> ; Search the Examples forum. Global $aArray, $hHandle, $iPID $iPID = Run('Notepad.exe') $aArray = _WinAPI_EnumProcessWindows($iPID) If @error Then Exit EndIf $hHandle = $aArray[1][0] While 1 If ProcessExists($iPID) = 0 Then ExitLoop EndIf $aArray = WinGetPos($hHandle) If $aArray[2] < 800 Then WinMove($hHandle, '', $aArray[0], $aArray[1], 800, $aArray[3]) EndIf If $aArray[3] < 600 Then WinMove($hHandle, '', $aArray[0], $aArray[1], $aArray[2], 600) EndIf Sleep(100) ; Reduce CPU. WEnd Yes, I guess so. Problem is, though, I'd like my users to be unable to resize these windows - but here the potential for resizing still exists. Adding the sleep(100), whilst decreasing CPU load for slower PCs, makes the GUI less fancy Thanks for your input though! I'm looking forwards to those by others
guinness Posted October 24, 2011 Posted October 24, 2011 Just delete the sleep. The two while functions weren't really needed in your example UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
BoonPek Posted October 26, 2011 Author Posted October 26, 2011 (edited) Thanks for your assistance. I'm going to assume that there's no other alternative to accomplish the OP other than what I specified? Anyways, onto another issue here xD In GUICtrlCreateInput, you could set the maximum of characters allowed for entry by using GUICtrlSetLimit($handle, maxvalue). Is this possible for a GUICtrlCreateCombobox? Once again, I'd prefer a native function. Thank you Edit: Fixed: _GUICtrlComboBox_LimitText() Edited October 26, 2011 by BoonPek
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