, Visual C#


- 4


myForm1.Show();

// Form1:

while (myForm1.Created)

{

myForm1.myRendering();

Application.DoEvents();

}

}

44.5. .

[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 = this.CreateGraphics();

Size s = this.Size;

myMemoryImage = new Bitmap(s.Width, s.Height,

myGraphics);

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

}

PrintDocument PrintDialog, PrintDocument. Form1.cs , ( ) .

44.6. .

private void printDocument1_PrintPage(object sender,

System.Drawing.Printing.PrintPageEventArgs e)

{

e.Graphics.DrawImage(myMemoryImage, 0, 0);

}

Print (. 44.7) . Form1.cs , .

44.7. .

private void button1_Click(object sender, EventArgs e)