用C#在 窗体中实现拍照和打印功能怎么办啊?
 请大家指教,谢谢!

解决方案 »

  1.   

    拍照可以通过SendKeys.SendKey("{Print Screen}"); 具体字符串记不清 查msnd 
    也可以用Control.SaveImgae打印看一下PringDialog类及相关的类 在Toolbox里有
      

  2.   

    /声明一个API函数
        [DllImport("gdi32.dll")]
        private static extern bool BitBlt(
            IntPtr hdcDest, // 目标 DC的句柄
            int nXDest,
          int nYDest,
          int nWidth,
          int nHeight,
          IntPtr hdcSrc,  // 源DC的句柄
            int nXSrc,
          int nYSrc,
          System.Int32 dwRop  // 光栅的处理数值
            );用这个函数就行了 private void button1_Click(object sender, System.EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;
            int temptop = this.Top;
            int templeft = this.Left;
            this.Top = 0;
            this.Left = 0;
            this.Hide();        System.Threading.Thread.Sleep(100);
            //获得当前屏幕的大小     
            Rectangle rect = new Rectangle();
            rect = Screen.GetWorkingArea(this);
            //创建一个以当前屏幕为模板的图象
            Graphics g1 = this.CreateGraphics();       
            //创建以屏幕大小为标准的位图       
            Image MyImage = new Bitmap(rect.Width,rect.Height,g1);
            Graphics g2 = Graphics.FromImage(MyImage);
            //得到屏幕的DC
            IntPtr dc1 = g1.GetHdc();
            //得到Bitmap的DC 
            IntPtr dc2 = g2.GetHdc();
            //调用此API函数,实现屏幕捕获
            //此处的0,0为本窗体的左上角坐标
            BitBlt(dc2, 0, 0, rect.Width, rect.Height, dc1, 0, 0, 13369376);
            //释放掉屏幕的DC
            g1.ReleaseHdc(dc1);
            //释放掉Bitmap的DC 
            g2.ReleaseHdc(dc2);
            //以JPG文件格式来保存
            MyImage.Save(@"c:\Capture.jpg", ImageFormat.Jpeg);
            MessageBox.Show("当前屏幕已经保存为C盘的capture.jpg文件!");        this.FormBorderStyle = FormBorderStyle.Sizable;
            this.Top = temptop; ;
            this.Left = templeft;
            this.Show();
        }
      

  3.   

    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
      

  4.   

     [DllImport("gdi32.dll")] 
     
     这个是什么意思?
     在没出来的啊,我是新手,可以说明一下吗?谢谢