![]() |
Shape beschriften oder alternative?
Hi,
gibt es eine möglichkeit einem Shape, irgendwie eine Caption zu geben, ohne z.b ein zusätzliches transparentes Label über das Shape zu legen, da ich Shape und Text als Einheit brauche. Welche alternative möglichkeit gäbe es denn, soetwas zu realisieren. Gruß DerNewbie |
Re: Shape beschriften oder alternative?
Hi,
am einfachsten dürfte es wohl sein, wenn du dir dafür eine eigene Shape-Komponente bastelst:
Delphi-Quellcode:
Das ganze kannst du dann entweder in die Komponentenpalette aufnehmen oder direkt einsetzen:
unit ExtShape;
interface uses ExtCtrls, Graphics; type TExtShape = class(TShape) protected procedure Paint; override; published property Caption; property Font; end; implementation { TCaptionShape } procedure TExtShape.Paint; begin inherited Paint; Canvas.Font := Font; Canvas.Brush.Style := bsClear; with Canvas do begin TextOut((Width - TextWidth(Caption)) div 2, (Height - TextHeight(Caption)) div 2, Caption); end; end;
Delphi-Quellcode:
with TExtShape.Create(Form1) do
begin parent := Form1; Font.Height := 30; Caption := 'Hallo!'; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:27 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