C # screenshot,
This example code saves WinForm screenshots as images.
Interface:
Download: http://hovertree.com/h/bjaf/scjyuanma.htm
The following code runs successfully in the HoverTreeCSJ project.
/* What asked the http://hovertree.com/hovertreescj/ */using System; using System. drawing; using System. drawing. imaging; using System. IO; using System. windows. forms; namespace HoverTreeSCJ. SCJForms. toolForms {public partial class Form_GetScreen: Form {public Form_GetScreen () {InitializeComponent ();} private void button_getScreen_Click (object sender, EventArgs e) {FormWindowState h_currentState = MdiParent. windowState; if (checkBox_isHide.Checked) {// MdiParent. hide (); // http://hovertree.com/h/bjaf/de7qg5wd.htm this. mdiParent. windowState = FormWindowState. minimized;} // create an image and save the Bitmap image = new Bitmap (Screen. primaryScreen. bounds. width, Screen. primaryScreen. bounds. height); Graphics imgGraphics = Graphics. fromImage (image); // set the screenshot area ke leyi imgGraphics. copyFromScreen (0, 0, 0, 0, new Size (Screen. primaryScreen. bounds. width, Screen. primaryScreen. bounds. height); // save SaveImage (image); if (checkBox_isHide.Checked) {this. mdiParent. windowState = h_currentState; // this. mdiParent. show () ;}// Save the Image file private void SaveImage (image Image) {// http://hovertree.com/h/bjaf/ruwwcg2p.htm saveFileDialog_getScreen.FileName = "" + DateTime. now. toFileTime (); if (saveFileDialog_getScreen.ShowDialog (this) = DialogResult. OK) {string fileName = saveFileDialog_getScreen.FileName; string extension = Path. getExtension (fileName); if (extension = ". jpg ") {image. save (fileName, ImageFormat. jpeg);} else {image. save (fileName, ImageFormat. bmp );}}}}}