Jump to content

Recommended Posts

Posted

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

  • 11 months later...
Posted

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.

  • 2 weeks later...
Posted

function TPaginaPrincipal.TextWidth(s: TUniLabel): Integer;
var
  c: TBitmap;
  f: TFont;
begin
{ 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;
  try
    c.Canvas.Font.Assign(f);
    Result := c.Canvas.TextWidth(s.Caption);
  finally
    c.Free;
  end;
end;
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...