Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Fillrect hat falschen Hintergrund (https://www.delphipraxis.net/202333-fillrect-hat-falschen-hintergrund.html)

skoschke 22. Okt 2019 09:20

Fillrect hat falschen Hintergrund
 
Hallo,

ich möchte in eine Bitmap ein schraffiertes Rechteck zeichnen:
Delphi-Quellcode:
 
  PaintBitmap.Canvas.Brush.Color := clAqua;
  PaintBitmap.Canvas.Brush.Style := bsDiagCross;
  PaintBitmap.Canvas.Pen.Color := clAqua;
  PaintBitmap.Canvas.FillRect(rect(10, 10, 100, 100));
Das funktioniert zwar, aber der Hintergrund der Schraffur ist schwarz anstelle wie gewünscht weiß!
Was habe ich übersehen?

Ciao
Stefan

Der schöne Günther 22. Okt 2019 10:27

AW: Fillrect hat falschen Hintergrund
 
Liste der Anhänge anzeigen (Anzahl: 1)
Delphi-Quellcode:
uses System.UITypes;

{$R *.dfm}

type
   TCanvasHelper = class helper for Vcl.Graphics.TCanvas
      procedure setBrushBackgroundColor(const color: TColor);
   end;

procedure TForm2.PaintBoxPaint(Sender: TObject);
var
   c: TCanvas;
begin
   c := (Sender as TPaintBox).Canvas;

   c.Brush.Style := TBrushStyle.bsDiagCross;
   c.Brush.Color := TColors.Aqua;
   c.setBrushBackgroundColor(TColors.Red);

   c.FillRect( TRect.Create(10, 10, 100, 100) );
end;

procedure TCanvasHelper.setBrushBackgroundColor(const color: TColor);
begin
   Win32Check( SetBkColor(Handle, color) <> 0 );
end;

DasZiesel 22. Okt 2019 15:27

AW: Fillrect hat falschen Hintergrund
 
Vielleicht weil dein Bitmap schwarz ist? Vorher einfach mit FillRect den Bereich weiß füllen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:48 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