Reputation: 6884
I'm using BCB6, but it should be the same as Delphi, if I just add a handler like this to my form:
void __fastcall TForm1::WndProc(TMessage &Message)
And handle WM_PAINT, I don't get the benefit of DoubleBuffered that TWinControl provides. Is there a way to do some custom painting on the form, that respects the DoubleBuffered setting (aka-writes to the memory bitmap TWinControl creates)?
This function in controls.pas is where the DoubleBuffered gets applied:
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
It creates a memory bitmap and then calls itself again. So I would need a way to call that function when Message.DC is 0, so it will create the bitmap and then I would not call it again after that... but WMPaint isn't virtual, and neither is PaintHandler, so I'm not seeing a way to hook in to this.
I know I can create my own double-buffering, but I would rather use what is already there if possible. I plan to carry this design over to other controls also, not just my form.
Upvotes: 2
Views: 1887
Reputation: 613053
Override the Paint
method rather than trying to handle WM_PAINT
messages. That way, the built in mechanism for double buffering will still be active, but you can customise your painting.
Upvotes: 5