Printing Window.Forms from Clipboard Image

S

sitemap

Hello guys,

I have a big problem with printing of windows.Forms :(

I have application with "print" button. I am trying to use
"e.Graphics.CopyFromScreen"... but in final result, over the
printing form appears other controls from the existing or new
applications in the screen ( Printing.. Please wait... - form for
example). I mean that "CopyFromScreen" getting all the forms in
defined coordinates and does not matter that the form that I want to
capture and print is bellow from "Printing.. Please wite" form -
for example.

I want to ask You:

If there any other way to do something like this:

// This happens in the main Form

Bitmap bt = new Bitmap(this);

//or

Bitmap bt = new Bitmap(Screen.FromControl(this));

Clipboard.SetImage(bt);


//Then i will get the image from the clipboard and print it....

If this is possible?
If Not, If the first variant ( using a CopyFromScreen ) have other
solutions?

Thank you in advance!!!
 
S

Stoitcho Goutsev \(100\)

Copy from screen does exactly what the name suggest. It takes snapshot of
the screen wahtever is currently visible.

If you your application takes snapshot of its own form you may want to try
to call form's DrawToBitmap method, but keep in mind that the best way of
doing this is to design your application in a way that it can draw itself
using arbitrary Graphics object. This way you can pass a graphics object
created out of a bitmap. DrawToBitmap uses Windows OS fetures to make a
window drawitself to a arbitrary HDC, but it doesn't work well in all of the
cases. As an example RichEdit control won't draw.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top