I have some code in which a memory metafile is created in the FormCreate
procedure, and then drawn onto a form by the FormPaint method.
Everything is OK until I drag the size of the form down to the point where
scroll bars appear. Then if I start to scroll the form, each scroll
generates another copy of the graphics, superimposed on all of the earlier
copies.
Here is the guts of my code ...
private
{ Private declarations }
PermMfHandle : HDC ; { Permanent MetaFile Device Context }
MyDC : HDC ; { Device Context for displaying Graphics }
BackColor : TColor ;
procedure TForm1.FormPaint(Sender: TObject);
begin
ReleaseDC(Handle,MyDC) ;
Canvas.Brush.Color := BackColor ; Canvas.Brush.Style := bsSolid ;
Canvas.FillRect(ClientRect) ;
MyDC := GetDC(Handle) ; { "Handle" to this window }
PlayMetaFile(MyDC,PermMfHandle) ;
end;
My assumption is that on each Scroll, there will be a call to FormPaint, and
that the Canvas.FillRect line will clear the screen and give PlayMetaFile a
clean slate to paint on. Obviously I am wrong. It almost seems as though
the background is transparent, and that the obsoleted graphics are showing
through. Can anyone point out where my error is, please ?
--- PPoint 2.00
---------------
* Origin: Kingston, Canada (1:249/109.11)
|