2007-01-05

C#模仿QQ截图功能

来源: CSDN 作者:往事随风 评论 0 条
 
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new CaptureScreenForm());
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
if(image != null)
{
this.picbox.Image = image;
}
else
{
this.picbox.Image = null;
this.picbox.Refresh();
}
}


// 引用API

[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
public static extern bool BitBlt(
IntPtr hdcDest, //目标设备的句柄
int nXDest, // 目标对象的左上角的X坐标
int nYDest, // 目标对象的左上角的X坐标
int nWidth, // 目标对象的矩形的宽度
int nHeight, // 目标对象的矩形的长度
IntPtr hdcSrc, // 源设备的句柄
int nXSrc, // 源对象的左上角的X坐标
int nYSrc, // 源对象的左上角的X坐标
System.Int32 dwRop // 光栅的操作值
);


private void exitBtn_Click(object sender, System.EventArgs e)
{
Application.Exit();
}

private void aboutBtn_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Code by Star in 2006-3-17,E_mail: ygh_01@163.com ,thank you to use this.");
}

private void ClearBtn_Click(object sender, System.EventArgs e)
{
CaptureScreenForm.image = null;
this.Invalidate();
}

private void saveBtn_Click(object sender, System.EventArgs e)
{
bool isSave = true;
SaveFileDialog saveImageDialog = new SaveFileDialog();
saveImageDialog.Title = "Capture screen image save dialog";
saveImageDialog.Filter= @"jpeg|*.jpg|bmp|*.bmp|gif|*.gif";

if(saveImageDialog.ShowDialog() == DialogResult.OK)
{
string fileName = saveImageDialog.FileName.ToString();

if(fileName != "" && fileName != null)
{
string fileExtName = fileName.Substring(fileName.LastIndexOf(".") 1).ToString();

System.Drawing.Imaging.ImageFormat imgformat = null;

if(fileExtName!="")
{
switch(fileExtName)
{
case "jpg":
imgformat = System.Drawing.Imaging.ImageFormat.Jpeg;
break;
case "bmp":
imgformat = System.Drawing.Imaging.ImageFormat.Bmp;
break;
case "gif":
imgformat = System.Drawing.Imaging.ImageFormat.Gif;
break;
default:
MessageBox.Show("只能存取为: jpg,bmp,gif 格式");
isSave = false;
break;
}

}

//默认保存为JPG格式
if(imgformat == null)
{
共8页: 上一页 [1] [2] 3 [4] [5] [6] [7] [8] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:Java应用web开发备用工具  
下一篇:详细讲述Java中的克隆
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号