Einzelnen Beitrag anzeigen

terence14
(Gast)

n/a Beiträge
 
#6

AW: Eigene Komponente: bekomme ein TLabel nicht transparent???

  Alt 14. Jan 2013, 18:55
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:

{-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;
MfG,
terence
  Mit Zitat antworten Zitat