Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to open a print screen when clicking a button.

I need coding for that in, Window application(ASP.NET) and web application(C#.NET).
Posted
Comments
#realJSOP 12-Oct-10 8:10am    
So, do you want to enable Print Screen, or do you want to print the contents of a page? Those are two COMPLETELY different things.

Hi, I hope thos helps you for creating a screenshot in a windows forms application.

int i = 0;
foreach (Screen a in Screen.AllScreens)
{
  Bitmap b = new Bitmap(a.WorkingArea.Width, a.WorkingArea.Height);
  Graphics g = Graphics.FromImage(b);
  g.CopyFromScreen(a.WorkingArea.Left, a.WorkingArea.Top, 0, 0, b.Size);
  g.Dispose();
  string location = "C:\\Temp\\" + i.ToString() + ".bmp";
  try
  {
    b.Save(location);
  }
  catch (System.Exception)
  {
    //Most probably a wrong path name or file sharing violation occured
  }
  finally
  {
    b.Dispose();
  }
  i++;
}
 
Share this answer
 
v2
Comments
Espen Harlinn 17-Jan-11 11:13am    
5+ A good answer
Hi,

I think you might be looking for the PrintDialog class.

See MSDN here[^]

Dave
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900