双缓冲不能减少闪烁
我正在面板中绘制对象的网格。当我快速滚动面板时,我会看到闪烁。我认为启用双缓冲可能会解决这个问题,但我发现它并没有完全绘制所有内容,并且留下了空白部分。 任何人都可以给我关于可能发生的情况以及我如何纠正它的建议。
更新:
我发现我正在使用 Creategraphics() 创建图形对象,而不是在绘制方法中使用参数
I am drawing an grid-work of objects in a Panel. when I scroll the the panel quickly I get a flicker. I thought that enabling the double buffering may take care of this but what I find is that it does not completely draw everything and I am left with blank sections.
could anyone give me suggestions as to what may be happening and how I might correct it.
UPDATE:
I found that I was creating the graphics object with Creategraphics() rather than using the Parameter in the paint method
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
双缓冲是怎么设置的?
您应该将控件的 DoubleBuffered 属性设置为 true
或
使用 SetStyle,并设置 OptimizedBoubleBuffer 和 AllPaintingInWmPaint
ControlStyles。AllPaintingInWmPaint 指示控件忽略 WM_ERASEBKGND 消息。这将减少您看到的闪烁,尤其是滚动时的闪烁。当将 DoubleBuffered 属性设置为 true 时,就暗示了这一点,事实上,它对 SetStyle 进行了与第二个示例中相同的调用。
How did you set the double buffering?
You should either set the DoubleBuffered property of the control to true
Or
Use SetStyle, and set both OptimizedBoubleBuffer and AllPaintingInWmPaint
ControlStyles.AllPaintingInWmPaint instructs the control to ignore WM_ERASEBKGND messages. This will reduce the flicker you see especially from the scrolling. This is implied with when setting the DoubleBuffered property to true, in fact it makes the same call to SetStyle as in the second example.