2014-10-13 177 views
0

我为我的用户控件打开了双缓冲。我画25x25方格。那些油漆就好了。图形闪烁

接下来我添加了一个50ms的计时器,我想每次绘制一个特定的正方形的边框。每个勾号都会稍微改变颜色。有用。

我的问题是,我得到一个讨厌的闪烁问题。

Me.SetStyle(ControlStyles.UserPaint, True) 
    Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) 
    Me.SetStyle(ControlStyles.DoubleBuffer, True) 

我已经打开了所有这一切,基于我的谷歌搜索。但我仍然有闪烁。我用尽了所有可以在互联网上找到的解决方案。有人可以帮助兄弟吗?

谢谢,

回答

0

我偶然发现一个解决方案。

相反Object.CreateGraphics的,使用以下使它无闪烁:

Dim currentContext As BufferedGraphicsContext 
Dim myBuffer As BufferedGraphics 
' Gets a reference to the current BufferedGraphicsContext. 
currentContext = BufferedGraphicsManager.Current 
' Creates a BufferedGraphics instance associated with Form1, and with 
' dimensions the same size as the drawing surface of Form1. 
BufferedG = currentContext.Allocate(Me.CreateGraphics, _ 
playGround.DisplayRectangle)