AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Gui Text fields problem

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
antonyb



Joined: 26 May 2004
Posts: 61

PostPosted: Mon Oct 24, 2005 4:12 pm    Post subject: Gui Text fields problem Reply with quote

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.
Back to top
View user's profile Send private message
kapege.de



Joined: 07 Feb 2005
Posts: 186
Location: Munich, Germany

PostPosted: Tue Oct 25, 2005 1:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group