TIP: Click on subject to list as thread! ANSI
echo: delphi
to: ALL
from: BRYAN SMITH
date: 1996-07-07 20:06:00
subject: Painting a MetaFile.

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.