printing with PrintDialog


K

Karl Christoph

I used this code but when i try nothing happens, i don't have any
other solution
there are no errors or something

(i'm sorry about my english)

private void menuItem9_Click(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
PrintDialog mDialog = new PrintDialog();
mDialog.Document = mDocument;
DialogResult mResult = mDialog.ShowDialog();
if (mResult == DialogResult.OK)
{
mDocument.Print();
}
}

[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc,
int nXSrc,
int nYSrc,
System.Int32 dwRop
);

private void mDocument_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
Graphics mGraphic = this.CreateGraphics();
Size s = this.Size;
Image memImage = new Bitmap(s.Width, s.Height, mGraphic);
Graphics memGraphic = Graphics.FromImage(memImage);
IntPtr dc1 = mGraphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height, dc1, 0, 0, 13369376);
mGraphic.ReleaseHdc(dc1);
memGraphic.ReleaseHdc(dc2);
e.Graphics.DrawImage(memImage,0,0);
}
 
Ad

Advertisements

C

Champika Nirosh

Hi,

Try with this change...

private void mDocument_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
Graphics mGraphic = e.Graphics;

I think this way it should work..

Nirosh..
 

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

Similar Threads


Top