AutoHotkey Community

It is currently May 27th, 2012, 3:24 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Gui Text fields problem
PostPosted: October 24th, 2005, 4:12 pm 
Offline

Joined: May 26th, 2004, 12:20 pm
Posts: 61
Hello,

I'm trying to write an app that displays some bits of information using Text controls. These bits of information are refreshed every second, and may change size (length). I'm trying to figure out how to display them correctly.

I start with a basic window, and declare the initial values:
Code:
Gui,+Owner +AlwaysOnTop -Disabled -SysMenu -Caption
Gui, Color, 000000
Gui, Font, s9 w700, Verdana

first=abc
second=def
third=ghi

then add the fields:
Code:
  y=10
  Gui,Font,c8B1A1A
  Gui,Add,Text,x10 y%y% vOne,%first%
  Gui,Font,cOlive
  Gui,Add,Text,x+7 y%y% vTwo,%second%
  Gui,Font,c408080
  Gui,Add,Text,x+7 y%y% vThree,%third%

Next I show the window:
Code:
Gui, Show, x200 y75 w305 h450, myWin

and kick off a timer that calls a function which updates my 3 vars:
Code:
SetTimer, Update, 1000

I want to write a method which updates the window. As I mentioned, its possible for the three values to change length, but I'd like to maintain the padding between them. My first thought was to kick of another timer that calls a Redraw function:
Code:
SetTimer, Redraw, 1000

Redraw:
  GuiControl,,One,%first%
  GuiControl,,Two,%second%
  GuiControl,,Three,%third%

However, this won't change the size of the Text controls, so if the new values are two long they won't be fully displayed, and if they're too short then the padding will appear to big. There's no way I can see to get a Text Control to resize itself according to its value.

Therefore, I really want to destroy the existing Text controls and replace them with new ones, but GuiControl, Delete isn't implemented yet.

Any ideas?

Thanks,

Ant.

EDIT: Alternatively, is there a way of using more than one color inside a text control? Then I could just pre-construct my text one line at a time.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 1:16 pm 
Offline

Joined: February 7th, 2005, 11:11 am
Posts: 192
Location: Munich, Germany
Try using fixed sizes (300px):
Code:
Gui, Add, Text, W300, %First%

Or you calc new sizes depending on the text length.
Code:
len := StrLen(First) * 15 ; The "15" has to adjust for Verdana
Gui, Add, Text, W%len%, %First%

Not perfect, but a beginning.

Peter


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], rbrtryn, Yahoo [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group