It wasn't "removed" - it's never existed in the CF. There a re a *lot* of
things not there, as indicated by the 80MB difference in size between the CF
and full FW.
Well, I did notice an inconsistency in the .NET framework
documentation since the list of platforms for Control.DrawToBitmap
includes PocketPC:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control...
While the list of methods DrawToBitmap does not have a PDA icon:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control...
I must have only seen the list of platforms and concluded that the
method was included.
The Smart Device Framework has a mechanism for a full screen shot[1]. For a
single control would be very similar - just using a different source DC.
You could also use the existing method and pass the Control bounds to get a
snapshot of just it.
Perfect, that could solve my problem. I am not sure if I can use the
OpenNETCF assemblies in my project though, since it runs on
Compact .NET 3.5 (and not on Compact .NET 2.0)?
Thanks, I'll give it a try!
Although I managed to get a bitmap of the control, I had to manually
adjust the coordinates. I would think that just using the control's
container's pointtoscreen method would suffice, but apparently the Y
coordinate would then be 26 pixels larger than it should be (the size
of the form's title bar I assume). Is this a bug or am I doing
something wrong?
Here's my code:
private Bitmap ControlToBitmap(Control c)
{
// copy the screen
Bitmap b = new Bitmap(c.Width, c.Height);
GraphicsEx ge =
GraphicsEx.FromGraphics(Graphics.FromImage(b));
int srcX = content.PointToScreen(c.Location).X;
int srcY = content.PointToScreen(c.Location).Y - 26;
int destX = 0;
int destY = 0;
Size size = c.Size;
ge.CopyFromScreen(srcX, srcY, destX, destY, size);
// cleanup
ge.Dispose();
return b;
}
I continually add and remove controls from the container (content),
and take screenshots of them. Sometimes the screenshot seems to
contain part of the previous control. Is there any way to force the
screen to repaint, so I don't have these side effects? Calling
invalidate doesn't seem to help.
The source code for CopyToScreen from OpenNETCF is not available as
far as I see, so I don't know how to copy only the control's into a
bitmap.
Any ideas?
Thanks in advance!
-- Jo