Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Activex get website that activex running on 3 85
calling procedure inside activexForm from secondform 1 232
Delphi application Soap connection 5 96
Multiple image collision 13 69
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…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

12 Experts available now in Live!

Get 1:1 Help Now