Jump to content

[CLOSED] Get the GUI size when all controls are visible


FireFox
 Share

Recommended Posts

FireFox mentioned wanting to make a UDF out of this.

It almost sounds like he wants to create a new "GuiCreate" that will automatically select the correct size of the gui based on where the controls are.

Such as if later you add new controls to the script, the gui would auto-resize to fit them all without adjusting the code.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

The easiest way I could think of to accomplish this would be to create an array of all the controls, then run through the array and grab the lowest X value, lowest Y value, highest X+control width value, and highest Y+control height value. But I believe it's already been mentioned as being not fast enough.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Well I was still getting it wrong.

After your suggestion of what the OP might be trying to do, I though it was taking as parameters

"buttons|2,edit|1,input|1,label|4" or something similar, and the calculations would be to arrange 2 buttons

1 edit, 1 input and 4 labels neatly into a gui and create it.

Like when you don't really care how they are arranged so long as they're all there type of thing.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@kaotkbliss

Thanks for pointing out what I said before. I'm not making an UDF for what you said, you will know when I will post it.

If it was only for my script, of course I would know the ctrl positions and this topic would not have any sense.

Anyway, thanks for your help.

Link to comment
Share on other sites

Might be useful:

Func ControlsGetMinMaxPos($hWnd)
    Local $iPosX_Min = 0xFFFF, $iPosX_Max, $iPosY_Min = 0xFFFF, $iPosY_Max
    Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD)
    Do
        $aRect = ControlGetPos($hChild, "", 0)
        If $aRect[0] < $iPosX_Min Then $iPosX_Min = $aRect[0]
        If $aRect[1] < $iPosY_Min Then $iPosY_Min = $aRect[1]
        If $aRect[0] +  $aRect[2] > $iPosX_Max Then $iPosX_Max = $aRect[0] +  $aRect[2]
        If $aRect[1] +  $aRect[3] > $iPosY_Max Then $iPosY_Max = $aRect[1] +  $aRect[3]
        $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
    Until Not $hChild
    Local $aMinMax[4] = [$iPosX_Min, $iPosY_Min, $iPosX_Max, $iPosY_Max]
    Return $aMinMax
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Very nice UEZ.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I will definitely use the function of UEZ.

Here is my version of jdelaney's function :

Func _WindowGetBoundCtrls($hWnd)
Local $aWndClassList = StringSplit(WinGetClassList($hWnd), @CRLF)
Local $sPriorClass, $iCounter = 1, $aBoundCtrls[2] = [0, 0], $aCtrlPos

If Not $aWndClassList[0] Then Return $aBoundCtrls
$sPriorClass = $aWndClassList[1]

For $iList = 1 To $aWndClassList[0] - 1
If $aWndClassList[$iList] <> $sPriorClass Then
$iCounter = 1
$sPriorClass = $aWndClassList[$iList]
EndIf

$aCtrlPos = ControlGetPos($hWnd, "", "[CLASSNN:" & $aWndClassList[$iList] & $iCounter & "]")

If $aCtrlPos[0] + $aCtrlPos[2] > $aBoundCtrls[0] Then $aBoundCtrls[0] = $aCtrlPos[0] + $aCtrlPos[2]
If $aCtrlPos[1] + $aCtrlPos[3] > $aBoundCtrls[1] Then $aBoundCtrls[1] = $aCtrlPos[1] + $aCtrlPos[3]

$iCounter += 1
Next

Return $aBoundCtrls
EndFunc   ;==>_WindowGetBoundCtrls
Link to comment
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
 Share

×
×
  • Create New...