I write a UserControl. The UserControl can show Speed. So I must use Bitmap.LockBits and then get Bitmap Start Address( BitmapData.Scan0 ). The code put UserControl OnPaint Event.
The code like following.
namespace CTest
{
public partial class uc_Thermometer_08 : UserControl
{
//protected override void OnPaint(PaintEventArgs e)
{
.........
unsafe
{
...........
bmpdat_Tmp = bmp_Tmp.LockBits(new Rectangle(0, 0, bmp_Tmp.Width-1,bmp_Tmp.Height-1),ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb);
byte_Ptr = (byte*)bmpdat_Tmp.Scan0;
int_Stride = bmpdat_Tmp.Stride;
........fill Color
bmp_Tmp.UnlockBits(bmpdat_Tmp);
}
}
}
I open other new project and put my UserControl on the form. It's ok. But I Close all project. And then I open again in vs2010. But the UserControl show error message as following situation.
But if I select the code edit page and close all project. I reopen all projects then select form design page. It show OK. Please give me a idea. Thanx.