PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Print problem

Reply

Print problem

 
Thread Tools Rate Thread
Old 21-10-2005, 02:58 AM   #1
=?Utf-8?B?Qi4gQ2hlcm5pY2s=?=
Guest
 
Posts: n/a
Default Print problem


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?

  Reply With Quote
Old 21-10-2005, 06:45 PM   #2
woutervu@hotmail.com
Guest
 
Posts: n/a
Default Re: Print problem

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

  Reply With Quote
Old 21-10-2005, 08:08 PM   #3
=?Utf-8?B?Qi4gQ2hlcm5pY2s=?=
Guest
 
Posts: n/a
Default Re: Print problem

I kind of suspected that. I'll just have to experiment.

Thanks!

"woutervu@hotmail.com" wrote:

> 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
>
>

  Reply With Quote
Old 22-10-2005, 02:19 PM   #4
Bob Powell [MVP]
Guest
 
Posts: n/a
Default Re: Print problem

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.





"B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
news:A5F9F02C-9F95-48E9-BC5A-D74613079027@microsoft.com...
>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?
>



  Reply With Quote
Old 22-10-2005, 11:37 PM   #5
=?Utf-8?B?Qi4gQ2hlcm5pY2s=?=
Guest
 
Posts: n/a
Default Re: Print problem

Actually no. The Parent property of every control is set to the picturebox.

"Bob Powell [MVP]" wrote:

> 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.
>
>
>
>
>
> "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
> news:A5F9F02C-9F95-48E9-BC5A-D74613079027@microsoft.com...
> >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?
> >

>
>
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off