Recent

Author Topic: Best container for timer text  (Read 3358 times)

jaden

  • New member
  • *
  • Posts: 7
Best container for timer text
« on: August 20, 2010, 07:04:37 am »
In a countdown timer I've written, the time is displayed in a TStaticText field.  I'm having a hard time getting automatic resize to work after the font size is changed within the app.  It starts up perfectly, but when the font is changed I can't figure out what to call to get it to auto-resize.  I've tried InvalidatePreferredSize, Repaint, Resize and AdjustSize without success. 

There's also a flicker when the numbers change (DoubleBuffered is set to true but it still flickers).

I'm experimenting with TImage, TShape and TPaintBox but I'm not sure of the best option.

Which component would work best to display the text with a user-definable font that would support automatic resizing and not flicker?

Is there a better way to do it?  I've thought about drawing the digits to look like LEDs, but Canvas.TextOut is so simple.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Best container for timer text
« Reply #1 on: August 20, 2010, 07:46:01 am »
To get zero-flickering and also being able to implement your own way of drawing fonts just go for a TCustomControl descendent: http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Create_a_custom_control_which_draws_itself

Then you can implement your LED-style number drawing routine for it.

You can draw your clock-style digits with narrow hexagons (TCanvas.Polygon).

jaden

  • New member
  • *
  • Posts: 7
Re: Best container for timer text
« Reply #2 on: August 20, 2010, 07:58:19 am »
Excellent.  Thanks for the quick reply.  I'll see how it works.

 

TinyPortal © 2005-2018