Windows XP上的DrawToBitmap

时间:2012-06-05 09:36:41

标签: c# winforms .net-4.0 windows-xp

我有一个用户控件,显示车辆的车牌号(它包含背景图像和一些TextBoxes),我使用DrawToBitmap()方法获取此控件的位图并在我的表单上显示位图,它在Windows 7上正常工作但在Windows XP Service Pack 3中只绘制了背景图像,并且未绘制文本框中的文本,我该怎么办?

var clt = new ControlLisenceTouch();Bitmap b = new Bitmap(clt.Width, clt.Height);
clt.License = License.FromCar(someCar);
clt.Invalidate(true);
clt.DrawToBitmap(b, Rectangle.FromLTRB(0, 0, clt.Width, clt.Height));
pictureBox1.Image = b;

1 个答案:

答案 0 :(得分:0)

这家伙有同样的问题,虽然答案并不完美,但确实为他做了。这里最大的问题是如果另一个窗口覆盖你的控件,那么该窗口也会显示出来。看看我的答案,第三个编辑显示屏幕截图,并从中裁剪控件。

How can I get a screenshot of control? DrawToBitmap not working

根据http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
完全支持Windows XP sp3