1
我有一个CF 2.0应用程序与图片框在窗体上。我想通过鼠标移动来移动PictureBox,并且需要将Double Buffer添加到窗体以避免闪烁。c#CF,WinForms和双缓冲区
我该怎么做?
谢谢!
我有一个CF 2.0应用程序与图片框在窗体上。我想通过鼠标移动来移动PictureBox,并且需要将Double Buffer添加到窗体以避免闪烁。c#CF,WinForms和双缓冲区
我该怎么做?
谢谢!
你不需要双缓冲窗体,你需要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提供...
PB? PB的含义是什么? – VansFannel 2009-02-22 17:21:12