, Visual C#


         


Graphics myMemoryGraphics =
Graphics.FromImage(myMemoryImage);
IntPtr dc0 = myGraphics.GetHdc();
IntPtr dc1 = myMemoryGraphics.GetHdc();
BitBlt(dc1, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height,
dc0, 0, 0, 13369376);
myGraphics.ReleaseHdc(dc0);
myMemoryGraphics.ReleaseHdc(dc1);
}
6.4. .
private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(myMemoryImage, 0, 0);
}
Print (. 6.1) . Form1.cs , :
myCaptureScreen();
.
6.5. PictureBox.
[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 myMemoryImage;
private void myCaptureScreen()
{
Graphics myGraphics = pictureBox1.CreateGraphics();
myMemoryImage = new Bitmap(
pictureBox1.Width,
pictureBox1.Height, myGraphics);
Graphics myMemoryGraphics =
Graphics.FromImage(myMemoryImage);
IntPtr dc0 = myGraphics.GetHdc();
IntPtr dc1 = myMemoryGraphics.GetHdc();
BitBlt(dc1, 0, 0, pictureBox1.ClientRectangle.Width,
pictureBox1.ClientRectangle.Height,
dc0, 0, 0, 13369376);
myGraphics.ReleaseHdc(dc0);
myMemoryGraphics.ReleaseHdc(dc1);
}