سلام دوستان من از فرمم پرینت میگیرم متهی دکمه فرمم پرینت گرفته میشه چیکار کنم گرفته نشه؟
[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()
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
private void button2_Click(object sender, EventArgs e)
{
CaptureScreen();
// printDocument1.Print();
//button2.Visible = false;
pageSetupDialog1.Document = printDocument1;
pageSetupDialog1.ShowDialog();
printPreviewDialog1.Document = printDocument1;
DialogResult re = printDialog1.ShowDialog();
if (re == DialogResult.OK)
{
printDocument1.Print();
}
else
{
MessageBox.Show(" print cancel");
// button2.Visible = true;
}
}