Jump to content
Sign in to follow this  
sensalim

Dynamic GUI window width?

Recommended Posts

sensalim

I have a combo box that is being filled by loading a text file.

I need the main GUI window width to increase or decrease depending on the longest (max width) item in that combo box.

How do I do that?

Thanks!

Share this post


Link to post
Share on other sites
Valuater

maybe...

#include<guiconstants.au3>
#include <file.au3>

$file = "C:\test.txt"
$width = 100
$info = ""
$aRecords = ""

If Not _FileReadToArray($file,$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aRecords[0]
    If (StringLen($aRecords[$x]) * 5.5) > $width Then $width = (StringLen($aRecords[$x]) * 5.5)
    $info = $info & $aRecords[$x] & "|"
Next
$info = StringTrimRight($info, 1)

GUICreate("My GUI", $width + 20, 100)
$Combo = GUICtrlCreateCombo("", 10, 10, $width)
GUICtrlSetData($Combo, $info)
GUISetState()

While GUIGetMsg() <> -3
WEnd

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
sensalim

So once GUICreate() is run, there is no way to modify the width of that window later on by a function?

Share this post


Link to post
Share on other sites
Monamo

So once GUICreate() is run, there is no way to modify the width of that window later on by a function?

Valuater's example should give you a working GUI sized appropriately for your question in your first post. As for resizing the GUI afterwards, you'd wanna use WinMove().

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites
RobertKipling

; GUI example
$gui = GuiCreate("Hi")

$width=500
$height=100
WinMove($gui, "", -1, -1, $width, $height)

I didn't figure out to use handles in the Win routines until later... I was missing out on a lot.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.