ScreenShot Maker [Well Explained Tutorial - C#]
Posted: Sun Sep 25, 2011 5:37 am
Create a new Windows From Application.
Add:
3 buttons
1 Picture Box
Details: Follow this tutorial and you won't be confused!
Double click on your form and put this code above everything.
Insert this under the public form1()
This basically means that when your going to take a screenshot for the application to hide first then take the screenshot as a bmp then show the application. This way we do not have the physical application in the picture.
Button1: Capture
This is basically your clear button. If you do not like the picture you just took this will clear your picture box.
Button2: Clear
Button3: Save
If you see any errors or mistakes please point them out!
Add:
3 buttons
1 Picture Box
Details: Follow this tutorial and you won't be confused!
Double click on your form and put this code above everything.
Code: Select all
This is just your simple dim's(I am use too VB.net so thats what i know them as)using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
Insert this under the public form1()
Code: Select all
Double click your form and insert this code for your capture button. {
InitializeComponent();
}
private static Bitmap bmpScreenshot;
private static Graphics gfxScreenshot;
This basically means that when your going to take a screenshot for the application to hide first then take the screenshot as a bmp then show the application. This way we do not have the physical application in the picture.
Button1: Capture
Code: Select all
Now you may use a button, toolstrip button or anything for this.{
this.Hide();
System.Threading.Thread.Sleep(1000);
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
pictureBox1.Image = bmpScreenshot;
System.Threading.Thread.Sleep(1000);
this.Show();
}
This is basically your clear button. If you do not like the picture you just took this will clear your picture box.
Button2: Clear
Code: Select all
This is how we will save your screenshot, this code tells the program too open a save window where you can chose where you want to save your image.{
pictureBox1.Image = null;
}
Button3: Save
Code: Select all
I hope this tutorial made sense and was helpful as this was my first C# tutorial!{
saveFileDialog1.FileName = "";
saveFileDialog1.ShowDialog();
try
{
pictureBox1.Image.Save(saveFileDialog1.FileName);
System.Diagnostics.Process.Start(saveFileDialog1.FileName);
saveFileDialog1.FileName = "";
}
catch
{
}
}
If you see any errors or mistakes please point them out!