[WinCE] WinCE上的双缓冲元件范例

WinCE上的.NET CF很多功能都省缺,因此很多地方只能靠自己....

就像双缓冲,一般Windows上用的作法是无法运作的

只好自己实践双缓冲元件

 

using System; using System.Drawing; using System.Windows.Forms; public class MyPictureBox : Control { private Image mImage; public Image Image { get { return mImage; } set { mImage = value; Invalidate(); } } protected override void OnPaintBackground(PaintEventArgs pevent) { // Do nothing } protected override void OnPaint(PaintEventArgs e) { using (Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height)) { using (Graphics bgr = Graphics.FromImage(bmp)) { bgr.Clear(this.BackColor); if (mImage != null) bgr.DrawImage(mImage, 0, 0); } e.Graphics.DrawImage(bmp, 0, 0); } base.OnPaint(e); } }

你可能感兴趣的:(windows,.net,image,null,Class,WinCE)