Hi. I have a program that prints a report to a printer. The report is created in code using a graphics object: GrObject = OpenPrinterDialog(PgSetup). This is working very well. Now I want to output the report to the screen (print preview), so I created a window with a canvas control on it. But a canvas wants a picture object, not a graphics object. What is the best way to get my report onto the canvas? This report is only one page so I am not concerning myself with page breaks at this time. I tried canvas.drawinto(GrObject, 0, 0) but nothing is painted.
create a picture pass its graphics object to your report printing code then put the picture on the canvas
Thanks for the tip Norman. In my print class I have two properties, GrObject as Graphics and GrPicture as Picture. In my open printer routine I have:
if ToScreen = True then
GrPicture = New Picture(3900,5100,16)
GrObject = GrPicture.Graphics
I then do the printing to the GrObject and pass it to the canvas which is on a new window:
dim pp as New PreviewWindow
pp.Canvas1.Refresh()
The paint event:
g = GrPicture.Graphics
My canvas is blank though, so I must still be missing something.
The paint event should be
g.DrawPicture GrPicture, 0, 0
Thanks Tim! That did the trick.