Solved

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

Posted on 2003-12-10
5
727 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

623 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