![]() |
Eigene Komponente: bekomme ein TLabel nicht transparent???
Hallo!
Ich erstelle eine eigene Komponente bestehend aus einem TCustomControl und einem TLabel. Die Komponente wird von TCustomControl abgeleitet. Über die gesammte Fläsche des Controls wird mit BitBlt ein Bitmap gezeichnet. Trasparent-Eigenschaft des Labels ist aktiviert. Eigentlich soll die Label ein trasparentes Hintergrund habe, doch das ist nicht der Fall. Stattdessen hat das Label die Farbe des Parents, auf dem die neu erstellte Komponente liegt, z.B. TForm oder TPanel. Was mache ich falsch? |
AW: Eigene Komponente: bekomme ein TLabel nicht transparent???
Ist Deine Komponente denn auch Parent des Labels?
|
AW: Eigene Komponente: bekomme ein TLabel nicht transparent???
Zitat:
|
AW: Eigene Komponente: bekomme ein TLabel nicht transparent???
Kannst Du mal ein bisschen Code zeigen? Andererseits frage ich mich, ob man nicht auf das Label verzichten und stattdessen direkt auf den Canvas des TCutomControls schreiben könnte.
|
AW: Eigene Komponente: bekomme ein TLabel nicht transparent???
Delphi-Quellcode:
vielleicht?
Label.ParentColor := false;
|
AW: Eigene Komponente: bekomme ein TLabel nicht transparent???
Hallo,
wie DeddyH bereits erwähnte, warum schreibst Du nicht direkt auf das BitMap Teil und verzichtest auf das Label? Ich mache das gerne so, weil ich dadurch einen Schatteneffekt dem Text hinzufügen kann.
Delphi-Quellcode:
MfG,{-14-} procedure _writeTextOnBMP(myImage: TImage; myText: string; myTextMaxWidth: integer); var x1, y1, tW, tH : integer; begin {-} if (myText = '') then exit; {-} myImage.Canvas.Font.Name:='Pristina'; myImage.Canvas.Font.Size:=10; myImage.Canvas.Font.Style:=[fsBold]; myImage.Canvas.Brush.Style:=bsClear; myImage.Canvas.CopyMode:=cmSRCCOPY; {-} tW:=myImage.Canvas.TextWidth(myText); {-} if (myTextMaxWidth = 0) then myTextMaxWidth:=myImage.Width - 2; {-} while (tW > myTextMaxWidth) do begin delete(myText, 12, 6); {-we start to remove 6 chars-} insert(' ... ', myText, 12); {-and add 5 new chars " ... "-} tW:=myImage.Canvas.TextWidth(myText); {-until tW <= myTextMaxWidth pixel-} end; {while} {-} tH:=myImage.Canvas.TextHeight(myText) + 2; {-} x1:=(myImage.Width - tW) div 2; y1:=(myImage.Height - tH) div 2; {-} myImage.Canvas.Font.Color:=clBlack; myImage.Canvas.TextOut(x1+1, y1+1, myText); myImage.Canvas.Font.Color:=clYellow; myImage.Canvas.TextOut(x1, y1, myText); {-} {-14-} end; terence |
AW: Eigene Komponente: bekomme ein TLabel nicht transparent???
Ich habe es letztendlich so gelöst, wie DeddyH vorgeschlagen hat. Ich zeichne den Text direkt auf der Canvas des Controls.
Vielen Dank an alle! |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:00 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