Thursday, February 3, 2011

Screen Shot into Clipboard


Bitmap ScreenShot;
int w = (int)aGrid.ActualWidth;
int h = (int)aGrid.ActualHeight;
int x = (int)aGrid.PointToScreen(new System.Windows.Point(0, 0)).X;
int y = (int)aGrid.PointToScreen(new System.Windows.Point(0, 0)).Y;
ScreenShot = new Bitmap(w, h);
Graphics g = Graphics.FromImage(ScreenShot);
g.CopyFromScreen(x, y, 0, 0, new System.Drawing.Size(w, h));
g.Dispose();

System.Windows.Forms.Clipboard.SetImage(ScreenShot);



No comments: