1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.IO;
namespace WindowsFormsApplication6
{
//public sealed class OpenFileDialog : FileDialog
//{
// OpenFileDialog1 dlgOuvrir = new OpenFileDialog1();
// dlgOuvrir.ShowDialog();
//}
public partial class MessageBox : Form
{
private PrintDocument myDocument;
//private PrintPageEventHandler pd_PrintPage;
public MessageBox()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
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, 50, 50, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 50, 50, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
private void BitBlt(IntPtr dc2, int p, int p_2, int p_3, int p_4, IntPtr dc1, int p_5, int p_6, int p_7)
{
}
private void btnOui_Click(object sender, EventArgs e)
{
PrintDialog printDialog1 = new PrintDialog();
DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
CaptureScreen();
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 50, 50);
}
} |
Partager