Print problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a PictureBox on a form. I have set up a print routine to send the
image to a printer, basically copied out of Help, with a
'e.Graphics.DrawImageUnscaled(PictureBox1.Image, 0, 0)' call in the
PrintPage event handler. The image prints ok.

One complication. This particular picturebox has a number of custom
controls sitting on it with the picture box defined as their parent. They
are not showing up in the print. How do I include them?
 
Hi,

this is kinda difficult to do. I recently built a similar application,
using an image as a map and pins on them which were controls. You will
have to manually paint the controls onto the Graphics object passed to
you in the event arguments. This is difficult because you need to take
scaling and such into account. You can add a Print method to your
custom controls from the Print method you can then call OnPaint using a
PaintEventArgs constructed by hand. I do not know for sure if this will
work for the default WinForms controls

Grtz, Wouter van Vugt
http://blogs.infosupport.com/wouterv
 
Try using the PrintWindow method to print directly to a bitmap. You may find
this works but I suspect that the controls on top of the picturebox are
siblings of the PB rather than children. Am I right?

If this is the case you may have to make all the controls children of a
Panel and call PrintWindow with the Panel's window handle.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top