0

我正在试验这段代码。

我在设计时有一个面板和一个按钮。另一个按钮和面板正在动态生成。我得到的结果图像不是显示省略号,而是显示按钮,我想知道为什么!?

    private void Form3_Load(object sender, EventArgs e)
    {

    }

    private void Form3_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = this.CreateGraphics();
        Pen pen = new Pen(Color.Black, 2);
        Brush brush = new SolidBrush(Color.White);
        Rectangle rect = new Rectangle(50, 50, 100, 200);
        Ellipse el = new Ellipse();
        el.Rectangle = rect;
        //g.DrawRectangle(pen, rect);
        g.DrawEllipse(pen, rect);

    }

    private void button1_Click(object sender, EventArgs e)
    {
        Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

        Graphics graphics = Graphics.FromImage(printscreen as Image);

        graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);

        printscreen.Save(@"C:\Temp\temp.jpg", ImageFormat.Jpeg);
    }
4

1 回答 1

0

我最终使用了 SendKeys.Send("{PRTSC}"); 它要简单得多。确保在它之前至少放置 2 秒睡眠:System.Threading.Thread.Sleep(2000);

于 2013-07-25T12:58:33.773 回答