AdvancedHMI Software

General Category => Tips & Tricks => Topic started by: oqapsking on May 03, 2017, 03:59:29 PM

Title: flickering solution
Post by: oqapsking on May 03, 2017, 03:59:29 PM
hello

i faced an annoying problem with my project

wich is  pictures and controls  flickering when loading the form

i found two solutions

1- set  DoubleBuffered to true in the form properties

2- put this code any where inside your form.vb

Code: [Select]
Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or &H2000000
            Return cp
        End Get
    End Property 'CreateParams


the second solution worked great for me

and i also kept DoubleBuffered  true


i hope this can help others


Title: Re: solution to solution flickering
Post by: Archie on May 03, 2017, 04:55:39 PM
Most of the AdvancedHMI controls use this code in a default constructor to limit flicker and allow transparent background:

Code: [Select]
    Public Sub New()
        MyBase.New

        '* reduce the flicker
        Me.SetStyle(System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer Or
                    System.Windows.Forms.ControlStyles.AllPaintingInWmPaint Or
                    System.Windows.Forms.ControlStyles.UserPaint Or
                    System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, True)

    End Sub
Title: Re: solution to solution flickering
Post by: Phrog30 on May 03, 2017, 06:33:59 PM
Funny, two posts about flickering in the same day.  Thanks for posting this Archie.

James