Jump to content
uniGUI Discussion Forums

label width

Recommended Posts

to place objects on the screen at runtime.

you have some method to indicate the width in pixel of a text

Delphi example: canvas.textwidth('Hello') or Canvas.textHeigth('Wordl')?

thanks for you help

Share this post

Link to post
Share on other sites

Correct. Width changes are not reflected back to the server. You need to design your app regardless of runtime width of components. Or you can set the AutoSize to False and set a fixed width.

Share this post

Link to post
Share on other sites

Hi Friends,


I too need to change my controls width a lot, and a automatic solution would be very nice.

We understand that sometimes we want to make better looking screens, so the controls must respond better to user commands and to run-time changes we made in the code.

I found a way that is working very well to me.

After you made any change that requires other controls to rearrange themselves, just put the code above:

Self.With := Self.With +1;
Self.With := Self.With -1;

Example of use: we put 2 panels and a splitter between then. They move fine, but if we have other controls inside those panels, and those controls are aligned with right, left or client, they won't resize unless you use the code I just mention.

Farshad Mohajeri did a great job with his framework, but he can't understand that simple issue is real.

Share this post

Link to post
Share on other sites

function TPaginaPrincipal.TextWidth(s: TUniLabel): Integer;
  c: TBitmap;
  f: TFont;
{ uma forma de calcular o tamanho de um texto na janela se o canvas não atualiza via ajax }
  c := TBitmap.Create;
  f := TFont.Create;
  Result := 8 * Length(s.Caption);
  f.Height := s.Font.Height;
  f.Size := s.Font.Size;
  f.Name := s.Font.Name;
  f.Style := s.Font.Style;
    Result := c.Canvas.TextWidth(s.Caption);

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