- Create a window application using MS Visual Studio.
- Add a Picture box and a Button.
Source Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging ;
using System.Text;
using System.Windows.Forms;
namespace screen_shot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int scrwidth = Screen.GetBounds(new Point(0, 0)).Width;
int scrheight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmp = new Bitmap(scrwidth, scrheight);
Graphics gfx = Graphics.FromImage((Image)bmp);
gfx.CopyFromScreen(0,0,0,0,new Size(scrwidth,scrheight));
bmp.Save(@"c:\test.jpg",ImageFormat.Jpeg);
}
}
}
No comments:
Post a Comment