You probably know how difficult it was to create a screen snapshot in CF v1. It required usage of many API calls and custom marshaling of a few structures. Just take a look at these resources:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/scibf.asp?frame=true
http://vault.netcf.tv/VaultService/VaultWeb/Blame.aspx?repid=2&path=%24%2fSDF%2fv1.4%2fOpenNETCF.Drawing%2fGDIPlus.cs&version=5&includedversions=20
The world has become a much better place since release of the CF v2 - availability of the native handles and ability to save image from Bitmap - have reduced the required code to just a few lines and one API call:
private void Snapshot(string filename, Graphics gx, Rectangle rect)
{
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
// Create compatible graphics
Graphics gxComp = Graphics.FromImage(bmp);
// Blit the image data
BitBlt(gxComp.GetHdc(), 0, 0, rect.Width, rect.Height, gx.GetHdc(), rect.Left, rect.Top, SRCCOPY);
bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp);
// Cleanup
bmp.Dispose();
gxComp.Dispose();
}
// P/Invoke declaration
[DllImport("coredll.dll")]
public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);
const int SRCCOPY = 0x00CC0020;
All you need to use it is just place the Snapshot method on your form and call it like that:
//Create a snapshot of a current view of the TextBox
Snapshot(@"\Temp\save.bmp", this.CreateGraphics(), textBox1.Bounds);