解決
Windows Form在執行後總會閃爍個好一陣子
方法一
1.設定DoubleBuffer=true,但效用似乎沒那麼大
方法二
C#
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
VB
Protected Overrides ReadOnly Property CreateParams As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H2000000
' Turn on WS_EX_COMPOSITED
Return cp
End Get
End Property
UserControl的Code
C#
protected override CreateParams CreateParams {
get {
var parms = base.CreateParams;
parms.Style &= ~0x02000000; // Turn off WS_CLIPCHILDREN
return parms;
}
}
VB
Protected Overrides ReadOnly Property CreateParams As System.Windows.Forms.CreateParams
Get
Dim parms As System.Windows.Forms.CreateParams = MyBase.CreateParams
'Turn off WS_CLIPCHILDREN
parms.Style = (parms.Style And (Not &H2000000))
Return parms
End Get
End Property
只要在Form上加入 Or &H2000000即可有效果,UserControl可不需加入那一段Code!
參考:亂馬客
沒有留言:
張貼留言