Autor Beitrag
Matty92
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: So 09.05.10 22:33 
Hi,
ich habe eine Paintbox, die ich mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button4Click(Sender: TObject);
begin
  brush.Color:=clwhite;
  paintbox1.Canvas.FillRect(PaintBox1.clientRect);
end;

lösche. Aber sobald sich ein Fenster über die Form legt, wird dieser Bereich weiß.
Wenn ich aber brush.color:=clbtnface; hinzufüge, ändert sich die Farbe der Form nicht, aber die Paintbox kriegt die Farbe des Fensters.
Kann man das irgendwie verhindern?

Viele Grüße,
Matty
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 09.05.10 22:35 
Du musst bei einer PaintBox schon OnPaint benutzen. Darüber wirst du benachrichtigt, dass der Inhalt der PaintBox neu gezeichnet werden muss, z.B. weil ein anderes Fenster diese verdeckt hat und dadurch der Inhalt weg ist.

In OnPaint muss dann der Inhalt der PaintBox neu gezeichnet werden.
Matty92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 11.05.10 19:37 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Du musst bei einer PaintBox schon OnPaint benutzen. Darüber wirst du benachrichtigt, dass der Inhalt der PaintBox neu gezeichnet werden muss, z.B. weil ein anderes Fenster diese verdeckt hat und dadurch der Inhalt weg ist.

In OnPaint muss dann der Inhalt der PaintBox neu gezeichnet werden.

Hm, ok. Hast du ein Codebeispiel zur Verwendung von onpaint? Ich werde aus der Delphihilfe nicht schlau.
Klappt das auch mit iterativen Zeichnen? Ich lasse in einer Schleife punkte zeichnen, die ich zuvor berechnete und die Punkte werden nirgendswo gespeichert.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Di 11.05.10 19:42 
user profile iconMatty92 hat folgendes geschrieben Zum zitierten Posting springen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button4Click(Sender: TObject);
begin
  brush.Color:=clwhite;
  paintbox1.Canvas.FillRect(PaintBox1.clientRect);
end;

Na, was fällt auf? Richtig, falscher Brush. Du meinst eher Paintbox.Canvas.Brush.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Matty92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 11.05.10 20:21 
Moderiert von user profile iconNarses: Komplett-Zitat des letzten Beitrags entfernt.

Danke :).
Das ist mir wirklich nicht aufgefallen. Ich wusste nicht, dass es verschiedene Brushes geben kann, das ist auch mein erstes Delphiprogramm mit GUI.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19322
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 11.05.10 20:40 
user profile iconMatty92 hat folgendes geschrieben Zum zitierten Posting springen:
Ich lasse in einer Schleife punkte zeichnen, die ich zuvor berechnete und die Punkte werden nirgendswo gespeichert.
Wenn du die nirgends speicherst, dann sind die eben weg, wenn das Gezeichnete verdeckt war.

Du kannst natürlich auch eine OffScreen-Bitmap nehmen.
Matty92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Mi 12.05.10 18:52 
Hi Jaenicke,
danke für den Link, das Umstellen hat prima geklappt, auch das Flackern hab ich mit doublebuffered:=true weggekriegt :).

Viele Grüße,
Matty