Showing posts with label print. Show all posts
Showing posts with label print. Show all posts

Tuesday, 28 June 2011

Printing the Form (Visual C#)

This example demonstrates printing a copy of the current form.
You may also use the PrintDocument component instead of PrintForm component with the same way.

This technique captures the gdi handler of the form and pastes it as image to the printer (as bitmap). It is not so good idea because the image has no good quality! If you plan to print photos and other material that requests high quality forget this technique and start to play drawing in the printer's canvas (i will show you in another post it is very easy).

Lest CODE!

[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{