Solved

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

Posted on 2003-12-10
5
710 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now