我在表单上有一个带有PictureBox的CF 2.0应用程序.我想用鼠标移动移动PictureBox,我需要在表单中添加Double Buffer以避免闪烁.
我怎样才能做到这一点?
谢谢!
你不需要双缓冲表,你需要PB.这在CF中并不容易.但是,您可以创建自己的控件,PB非常简单.例如:
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); } }
希望我没有使用CF中没有的东西......