Solved

Creating a tmetafilecanvas and "inherit" the image already drawn on the tmetafile

Posted on 2003-12-10
5
713 Views
Last Modified: 2012-08-14
Hi there,

I have a list of TMetafiles with images already drawn on them. Now I need to be able to create a TMetafilecanvas for a specific metafile in the list, and the draw on top of the image already on the metafile.

My list is a tobjectlist and the code i have so far is

mymetacanvas := tmetafilecanvas.create(tmetafile(mymetafilelist[index]),printer.handle);

then some drawing

and finally
 
mymetacanvas.free;


when I use this code I get the drwaing done is this last bit of code shown just fine, but the image I had drawn previosly is gone.

What to do ?

Best regards
NetGeek


0
Comment
Question by:NetGeek
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:odissey1
ID: 9914129
Hi NetGeek,

Create Temp metacanvas
Draw tmetafile(mymetafilelist[index]),
Add extra drawing,
Send to printer ot assign to tmetafile(mymetafilelist[index]).

Well, I am sure you are already accomplished that...
regards,
odissey1
0
 

Author Comment

by:NetGeek
ID: 9914167
Hi odissey1,

I'm not sure that will work (if Iøve understood you correctly). If you could show me some real code how to do it, maybe I'll see the light

NetGeek
0
 
LVL 2

Expert Comment

by:odissey1
ID: 9914299
Hi NetGeek,

I can't work on the code  right now - I'm on my job. I'll try later. Please let us know if you accomplish this before.

odissey1
0
 
LVL 5

Accepted Solution

by:
delphized earned 125 total points
ID: 9915296
directly from Delphi Help
cut and paste:

This example shows how to create or augment a metafile using a metafile canvas object.  This metafile can then be used to draw on the canvas of another object such as a paintbox or a printer.

MyMetafile := TMetafile.Create;

with TMetafileCanvas.Create(MyMetafile, 0) do
try
  Brush.Color := clRed;
  Ellipse(0,0,100,100);
  ...
finally
  Free;

end;

Form1.Canvas.Draw(0,0,MyMetafile); {1 red circle }

To add to an existing metafile image, create a metafile canvas and play the source metafile into the metafile canvas:

with TMetafileCanvas.Create(MyMetafile, 0) do

try
  Draw(0,0,MyMetafile);
  Brush.Color := clBlue;
  Ellipse(100,100,200,200);
...
finally
  Free;
end;

Form1.Canvas.Draw(0,0,MyMetafile); {1 red circle and 1 blue circle }
0
 

Author Comment

by:NetGeek
ID: 9918801
excellent, delphized

the Draw(0,0,MyMetafile); did the trick just nicely.

Just shows that you should first read the help thoroughly before seeking help elsewhere, but who ever reads the help ;)

thank you very much

NetGeek
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question