Discussion:
printing metafiles
(too old to reply)
Mike Glazer
2008-05-18 14:35:13 UTC
Permalink
I have the following code in Delphi where I am trying to print a metafile:

Printer.BeginDoc;

Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth-1,
Printer.PageHeight-1),m);

Printer.EndDoc;

But Dephi7 objects with the message
[Error] (1036): Incompatible types: 'TGraphic' and 'TMetafile'
Any ideas?
Mike G
Jamie
2008-05-18 17:32:58 UTC
Permalink
Post by Mike Glazer
Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth-1,
Printer.PageHeight-1),m);
Printer.EndDoc;
But Dephi7 objects with the message
[Error] (1036): Incompatible types: 'TGraphic' and 'TMetafile'
Any ideas?
Mike G
Create a Tpicture Object first..

MyPictureObject.Assign(M);
then pass the MyPictureObject instead of the M.

remember to free it at some point after printing for example.


http://webpages.charter.net/jamie_5"
Rob Kennedy
2008-05-19 04:46:22 UTC
Permalink
Post by Jamie
Post by Mike Glazer
Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth-1,
Printer.PageHeight-1),m);
Printer.EndDoc;
But Dephi7 objects with the message
[Error] (1036): Incompatible types: 'TGraphic' and 'TMetafile'
And m is declared as a Graphics.TMetafile? And Printer is the one from
the Printers unit? That error shouldn't happen. TMetafile is a direct
descendant of TGraphic.

Please provide more context.
Post by Jamie
Create a Tpicture Object first..
MyPictureObject.Assign(M);
then pass the MyPictureObject instead of the M.
Then it won't even compile. TPicture is not a TGraphic, but StretchDraw
requires a TGraphic.
Post by Jamie
remember to free it at some point after printing for example.
--
Rob
Mike Glazer
2008-05-19 07:10:28 UTC
Permalink
That's it! Rob's question about the Printer unit made me realise that I
didnt declare the Printers in the uses clause!
Problem solved.
Many thanks
Mike

Continue reading on narkive:
Loading...