I am developing an application for Windows 7 and thinking about migrating to Windows 8. The problem is that when using CopyFromScreen for my screen capture operation, I'm noticing it does not capture the entire desktop on Windows 8 (only the top-left quadrant). It works perfectly on Windows 7. The code I am using is:
try
{
// Thread gives tooltip highlight time to disappear; can be made faster
System.Threading.Thread.Sleep(1000);
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics g = Graphics.FromImage((Image)bmpScreenShot);
Rectangle bounds = new Rectangle(Location, Size);
g.CopyFromScreen(0, 0, 0, 0, bounds.Size);
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "JPEG Image|*.jpg| PNG image | *.png";
dialog.Title = "Save As";
dialog.ShowDialog();
if (dialog.FileName != "")
{
FileStream fstream = (FileStream)dialog.OpenFile();
switch (dialog.FilterIndex)
{
case 1:
bmpScreenShot.Save(fstream, ImageFormat.Jpeg);
break;
case 2:
bmpScreenShot.Save(fstream, ImageFormat.Png);
break;
}
fstream.Close();
}
}
catch
{
}
finally
{
}
Could somebody please tell me why this isn't working ... Thanks for your help ...