admin管理员组文章数量:1532180
2024年7月2日发(作者:)
C#WinForm简单桌面截屏工具
开发环境:Visual Studio 2005
窗体设计器代码
namespace PrintScreen
{
partial class Form1
{
///
/// 必需的设计器变量。
///
private iner components = null;
///
/// 清理所有正在使用的资源。
///
/// 如果应释放托管资源,为 true;否则为 false。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
e();
}
e(disposing);
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
///
private void InitializeComponent()
{
entResourceManager resources = new
entResourceManager(typeof(Form1));
ntScreen = new ();
oom = new ();
eImg = new ();
leDialog1 = new leDialog();
= new ();
eBox1 = new eBox();
ntCScreen = new ();
dLayout();
dLayout();
((rtInitialize)(eBox1)).BeginInit();
dLayout();
//
// btnPrintScreen
//
on = new (324, 4);
= "btnPrintScreen";
= new (107, 23);
ex = 0;
= "截屏到剪切板";
ualStyleBackColor = true;
+= new
andler(ntScreen_Click);
//
// pnlBotoom
//
(ntCScreen);
(eImg);
(ntScreen);
= ;
on = new (0, 426);
= "pnlBotoom";
= new (756, 28);
ex = 1;
//
// btnSaveImg
//
on = new (472, 4);
= "btnSaveImg";
= new (107, 23);
ex = 1;
= "保存当前图";
ualStyleBackColor = true;
+= new andler(eImg_Click);
//
// saveFileDialog1
//
= "BMP图片(*.bmp)|*.bmp|Jpg图片(*.jpg)|*.jpg|Jpeg
图片(*.Jpeg)|*.Jpeg|PNG图片(*.png)|*.png|Gi" +
"f图片(*.gif)|*.gif";
= "保存图片";
//
// pnlImg
//
(eBox1);
= ;
on = new (0, 0);
= "pnlImg";
= new (756, 426);
ex = 2;
//
// pictureBox1
//
= ;
on = new (0, 0);
= "pictureBox1";
= new (756, 426);
de =
hImage;
ex = 0;
p = false;
//
// btnPrintCScreen
//
on = new (176, 4);
= "btnPrintCScreen";
= new (107, 23);
ex = 2;
= "截 屏";
ualStyleBackColor = true;
+=
andler(ntCScreen_Click);
//
// Form1
//
aleDimensions = new (6F, 12F);
aleMode = ;
Size = new (756, 454);
();
(oom);
= (()(ect("$")));
zeBox = false;
zeBox = false;
= "Form1";
osition
sDefaultBounds;
= "截屏";
+= new andler(1_Load);
Layout(false);
Layout(false);
((rtInitialize)(eBox1)).EndInit();
Layout(false);
}
#endregion
private btnPrintScreen;
private pnlBotoom;
private btnSaveImg;
private leDialog saveFileDialog1;
private pnlImg;
private eBox pictureBox1;
private btnPrintCScreen;
}
}
窗体代码:
using System;
using c;
new
=
using entModel;
using ;
using g;
using ;
using ;
namespace PrintScreen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region [成员函数]
///
/// 图像函数
///
private Image _img;
#endregion
#region [方法]
///
/// 截屏
///
private void PrintScreen()
{
try
{
Screen scr = yScreen;
Rectangle rc = ;
int iWidth = ;
int iHeight = ;
Bitmap myImage = new Bitmap(iWidth, iHeight);
Graphics g1 = age(myImage);
omScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth,
iHeight));
_img = myImage;
}
catch (Exception ec)
{
("截屏失败!n" + ng() + "n" +
ng());
}
}
#endregion
#region [事件]
private void Form1_Load(object sender, EventArgs e)
{
//截屏并显示到PictureBox
PrintScreen();
if (_img != null)
{
= _img;
}
}
///
/// 保存图像到文件
///
///
///
private void btnSaveImg_Click(object sender, EventArgs e)
{
me = "";//清空名称栏
if ( == alog())
{
string strFileName = me;
Image img = (Image);
(strFileName);
}
}
///
/// 截屏当前桌面到剪切板
///
///
///
private void btnPrintScreen_Click(object sender, EventArgs e)
{
PrintScreen();
if (_img != null)
{
aObject(_img);
}
}
///
/// 截屏当前图像到PictureBox
///
///
///
private void btnPrintCScreen_Click(object sender, EventArgs e)
{
State = zed;
PrintScreen();
if (_img != null)
{
= _img;
}
State = ;
}
#endregion
}
}
版权声明:本文标题:C#WinForm简单桌面截屏工具 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1719891978a805038.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论