Previous | Index | Next 

[HOWTO] Reduce flickering when loading or resizing a form with many controls

By default, .NET forms refresh the background each time a new control becomes visible. If the form has many controls and a background picture, this mechanism creates a lot of flickering. This happens with both native and migrated forms.

If you are working with a native .NET form you can remarkably reduce the flickering by adding the following code to your form:

        Protected Overrides ReadOnly Property CreateParams() As CreateParams
                Dim params As CreateParams = MyBase.CreateParams
                params.ExStyle = params.ExStyle Or &H2000000
                Return params
            End Get
        End Property

For extra ease of our users, we have added this feature to our VB6Form class. If you experience a lot of flickering when loading a form, all you need to do is setting the VB6Config.UseExCompositeStyle property to True when your app starts its execution:

        Sub Main()
            VB6Config.UseExCompositeStyle = True
        End Sub

If your project doesn’t have a Sub Main, you should insert the statement in the startup form’s static constructor:

        Shared Sub New()
            VB6Config.UseExCompositeStyle = True
        End  Sub 


Previous | Index | Next