Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Bitmap in Statusbar transparent zeichnen will ... - erledigt (https://www.delphipraxis.net/136765-bitmap-statusbar-transparent-zeichnen-will-erledigt.html)

turboPASCAL 7. Jul 2009 18:14


Bitmap in Statusbar transparent zeichnen will ... - erledigt
 
Hi,

Ich mochte ein Bitmap in ein Panelteilchen einer Statusbar transparent zeichnen.
Zeichnen klappt aber die Transparenz fehlt.

Was mach ich denn nicht richtig ?
Liegt es vill. an CopyRect ?

So schauts aus:

Delphi-Quellcode:
 // Bitmap für Statusanzeige erstellen
  StatusBitmap := TBitmap.Create;
  try
    // Bilder für Statusanzeige laden
    StatusBitmap.LoadFromResourceID(hInstance, 300);
    StatusBitmap.Transparent := true;  
    StatusBitmap.TransparentColor := StatusBitmap.Canvas.Pixels[0,0];

    StatusBar1.Panels[0].Width := StatusBar1.ClientWidth - StatusBitmap.Width - 8; // -8 wegen Umrandung bzw. Trenner
  except


//  ------------ * schnipp * --------------

procedure TfrmGameWnd.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const _Rect: TRect);
begin
  if Panel = StatusBar1.Panels[1] then // zweites Panel
  begin
    with StatusBar.Canvas do
    begin
      if UnitExtras.Optionen.Sound <> 0 then
        CopyRect( RECT(_Rect.Left, _Rect.Top,_Rect.Left+16,_Rect.Top+16), StatusBitmap.Canvas, RECT(0,0,16,16));

      if UnitExtras.Optionen.BKMusik then
        CopyRect( RECT(_Rect.Left+16, _Rect.Top,_Rect.Left+16+16,_Rect.Top+16), StatusBitmap.Canvas, RECT(16,0,16+16,16));
    end;
  end;
end;
// Edit:
Ja, es liegt an CopyRect, man nutze TransparentBlt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:32 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz