对不起,我的英语不好。我是这里的新手,也是 C# 的新手。我需要帮助屏幕捕获包含 PictureBox 中的图像和 TextBox 中的文本的表单区域。一切都很好,只是截图的保存图像不包含 PictureBox 中的图像和 TextBox 中的文本。我究竟做错了什么?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class ID_Editor_Form : Form
{
Image File;
int TogMove; int MValX; int MValY;
public ID_Editor_Form()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
TogMove = 1; MValX = e.X; MValY = e.Y;
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
TogMove = 0;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (TogMove == 1)
{
this.SetDesktopLocation(MousePosition.X - MValX, MousePosition.Y - MValY);
}
}
OpenFileDialog BrowseID = new OpenFileDialog();
private void button3_Click(object sender, EventArgs e)
{
BrowseID.Filter = "JPG|*.jpg|JPEG|*.jpeg|PNG|*.png|All Files|*.*";
if (BrowseID.ShowDialog() == DialogResult.OK)
{
File = Image.FromFile(BrowseID.FileName);
pictureBox2.Image = File;
}
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap bitmap = new Bitmap(this.Width, this.Height - 48);
DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
bitmap.Save("C:\\Users\\ROBO\\Desktop\\Screen.png", ImageFormat.Png);
MessageBox.Show("Saved Completed");
}
}
}