2014-10-13 178 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)