Показать сообщение отдельно
  #3  
Старый 29.01.2017, 07:34
lmikle lmikle вне форума
Модератор
 
Регистрация: 17.04.2008
Сообщения: 8,015
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
По умолчанию

Цитата:
Сообщение от lmikle
Код:
Label.Font.Style := Label.Font.Style + [fsUnderline]
не?

Специально кодом все сделал:
Код:
procedure TForm1.Button1Click(Sender: TObject);
const
  Str = 'die U-Bahn-Station';
  MonoFontName = 'Courier';
  MonoFontSize = 18;
  MonoFontSpace = 4;
var
  L : TLabel;
  X, Y, D : Integer;
  I : Integer;
  tmpFontName : String;
  tmpFontSize : Integer;
begin
  Y := Button1.Top + Button1.Height + 8;
  X := Button1.Left;

  tmpFontName := Self.Font.Name;
  tmpFontSize := Self.Font.Size;
  Self.Font.Name := MonoFontName;
  Self.Font.Size := MonoFontSize;
  D := Self.Canvas.TextWidth('W') + MonoFontSpace;
  Self.Font.Name := tmpFontName;
  Self.Font.Size := tmpFontSize;


  For I := 1 To Length(Str) Do
    Begin
      L := TLabel.Create(Self);
      L.Font.Name := MonoFontName;
      L.Font.Size := MonoFontSize;
      If Str[i] <> ' ' Then L.Font.Style := L.Font.Style + [fsUnderline];
      L.Left := X;
      L.Top := Y;
      L.Caption := Str[i];
      X := X + D;
      L.Parent := Self;
    End;
end;

Только надо шрифт правильный подобрать - походу нужен моноширинный. У меня почемуто Courier New отказался подчеркиваться.
Изображения
Тип файла: bmp fontDemo.bmp (326.3 Кбайт, 6 просмотров)
Ответить с цитированием