AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Gedrehter Text nicht sichtbar?

Offene Frage von "Phoenix"
Ein Thema von Phoenix · begonnen am 4. Jul 2007 · letzter Beitrag vom 4. Jul 2007
 
Benutzerbild von Phoenix
Phoenix
(Moderator)

Registriert seit: 25. Jun 2002
Ort: Hausach
7.643 Beiträge
 
#1

Gedrehter Text nicht sichtbar?

  Alt 4. Jul 2007, 08:53
Hi *.*

Ich habe aus diesem Tipp und diesem Thread hier ein Control gebaut, welches drehbaren Text enthalten soll.

Daraus ergab sich folgender Code in meiner Paint-Routine:

Delphi-Quellcode:
procedure TASCustomVisuPanel.Paint;
const
  Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
var
  Rect: TRect;
  FontHeight: Integer;
  Flags: Longint;
  LogFont: TLogFont; // drehbarer Text
  TempFont: TFont;
begin
  Rect := GetClientRect;

  // Hintergrund zeichnen:
  if not Assigned(FBackgroundBitmap)
    and not ThemeServices.ThemesEnabled
    or not ParentBackground then
  begin
    Canvas.Brush.Color := Color;
    Canvas.FillRect(Rect);
  end;

  // Hintergrundbild einzeichnen:
  if Assigned(FBackgroundBitmap) then
  begin
    BitBlt(Canvas.Handle, Rect.Left, Rect.Top, Self.ClientWidth,
      Self.ClientHeight, FBackgroundBitmap.Canvas.Handle, 0, 0, SRCCOPY);
  end;

  // Rahmen zeichnen
  if BevelOuter <> bvNone then
  begin
    Frame3D(Canvas, Rect, FColorBorder, FColorBorder, BevelWidth);
  end;

  Frame3D(Canvas, Rect, Color, Color, BorderWidth);

  if BevelInner <> bvNone then
  begin
    Frame3D(Canvas, Rect, FColorBorder, FColorBorder, BevelWidth);
  end;

  Canvas.Brush.Style := bsClear;
  Canvas.Font := Self.Font;
  FontHeight := Canvas.TextHeight('W');

  // Text ggf. drehen:
  if not (FTextAngle = 0) then
  begin
    TempFont := TFont.Create;
    try
      TempFont.Assign(Canvas.Font);

      GetObject(TempFont.Handle, SizeOf(LogFont), @LogFont);
      LogFont.lfEscapement := 10 * FTextAngle;
      LogFont.lfOrientation := 10 * FTextAngle;
      TempFont.Handle := CreateFontIndirect(LogFont);

      Canvas.Font.Assign(TempFont);
    finally
      FreeAndNil(TempFont);
    end;
  end;

  with Rect do
  begin
    Top := ((Bottom + Top) - FontHeight) div 2;
    Bottom := Top + FontHeight;
  end;

  Flags := DT_EXPANDTABS or DT_VCENTER or Alignments[FAlignment];
  Flags := DrawTextBiDiModeFlags(Flags);
  DrawText(Canvas.Handle, PChar(Caption), -1, Rect, Flags);
end;
Das funktioniert nur leider nicht.

Nehme ich als Font z.B. Courier - also einen Font der nicht TrueType ist, wird dieser ganz normal horizontal gezeichnet. - Schliesslich soll das ja auch lt. Jens gar nicht funktionieren.

Benutze ich nun aber einen TrueType-Font, so sehe ich gar keinen Text.

Was geht da schief?
Sebastian Gingter
Phoenix - 不死鳥, Microsoft MVP, Rettungshundeführer
Über mich: Sebastian Gingter @ Thinktecture Mein Blog: https://gingter.org
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:37 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz