我做了个游戏,老是闪烁,大家都说用双缓冲。
谁有关于双缓冲的例子,最好有注释。
谢谢!
谁有关于双缓冲的例子,最好有注释。
谢谢!
解决方案 »
- C# 控件问题,那个空间能实现这个效果
- 如何设置解决方案,使得两个exe按设定次序运行
- 把ftp位址變成一個硬盤的程式
- Socket线程池的问题!!!!!!!!
- 高手来 winform数据分条查询 得分好题
- 关于GridView读取
- 各位哥哥姐姐,帮个忙,我实在不知道怎么做了...
- 急:如何重写RICHTEXTBOX的背景图像?UP有分
- 线程终止问题
- 2个richtextbox中的文本互相比较,在不同处标红,那位老兄有好的算法?
- 一个SQL server统计问题
- 用C#写了个安装程序,由于在uninstall方法里自己写了点代码抛出了异常,每次运行到这里就会回滚,现在没法卸载这个软件了(用Windwos自带的卸载都不行了)
你百度一下doublebufferlistview
兴许就找到问题的答案喽,good luck
class DoubleBufferListView : ListView
{
public DoubleBufferListView()
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}//
DoubleBufferListView lv=new DoubleBufferListView();
lv...
...
才十五分而已,还好拿意思,我每次求贴都是一百分...呵呵
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;namespace SquareWave
{
public partial class MainForm : Form
{
public SW swMain; private BufferedGraphics backBuffer; //双缓冲的缓冲区。 private BufferedGraphics backgroundBuffer; //背景缓冲区:坐标轴,刻度,参考线
public MainForm(SW sw)
{
InitializeComponent(); this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.ResizeRedraw |
ControlStyles.AllPaintingInWmPaint, true); if (sw == null)
{
sw = new SW(changeSWPos);
}
else
{
sw.SetChangeHandle(changeSWPos);
} swMain = sw;
swMain.DoSWPChanged();
}
private void changeSWPos(int Left, int Top, int Width, int Height)
{
panRight.Refresh();
nudT.Value = swMain.TimeStart;
nudR.Value = swMain.RangeValue;
nudP.Value = swMain.PersistTime;
txtSWPos.Text = "[" + Left.ToString() + "," + Top.ToString() + "] [" + Width.ToString() + "," + Height.ToString() + "]";
}
public const int opX = 30;
public const int opY = 310; public const int dX = 50;
public const int dY = 50; public const int cX = 8;
public const int cY = 6; public int HFramePos;
public int VFramePos;
#region 绘图方法 private void panRight_Paint(object sender, PaintEventArgs e)
{
//手工绘制坐标轴
if (backgroundBuffer == null)
{
Rectangle rect = e.ClipRectangle;
BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
backgroundBuffer = currentContext.Allocate(e.Graphics, e.ClipRectangle);
backgroundBuffer.Graphics.SmoothingMode = SmoothingMode.HighQuality;
backgroundBuffer.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed; Graphics gBG = backgroundBuffer.Graphics;
gBG.Clear(Color.White);
drawAXIS(gBG); //绘制坐标轴
drawTEXTRefLine(gBG); //绘制坐标轴文字
} if (backBuffer == null)
{
Rectangle rect = e.ClipRectangle;
BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
backBuffer = currentContext.Allocate(e.Graphics, e.ClipRectangle);
backBuffer.Graphics.SmoothingMode = SmoothingMode.HighQuality;
backBuffer.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
}
//用背景缓冲区渲染双缓冲
backgroundBuffer.Render(backBuffer.Graphics); Graphics g = backBuffer.Graphics; drawSW(g); //绘制方波
drawFrame(g); //绘制拖放时的边框
backBuffer.Render(e.Graphics); //双缓冲防闪烁(暂时未达到效果) }
}
}
{
public DoubleBufferListView()
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}
把这个ListView改成其它的不可用吗?