Jump to content

label width


mayusod

Recommended Posts

  • 11 months later...

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.

Link to comment
Share on other sites

  • 2 weeks later...

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;
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...