Page 1 of 1

Controls Flickering?

Posted: Sat Jan 07, 2017 1:48 pm
by Dummy1912
Hello,

We have created our own controls and seems after run
we gets white flickering loading the forms

All our controls have the same code:
Code: Select all
Protected Overrides Sub OnCreateControl()
        MyBase.OnCreateControl()
        Try
            ParentForm.FormBorderStyle = FormBorderStyle.None
            ParentForm.AllowTransparency = False
            ParentForm.TransparencyKey = Color.Fuchsia
            ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
        Catch ex As Exception
        End Try
        DoubleBuffered = True
        Dock = DockStyle.Fill
        TabStop = False
        Invalidate()
    End Sub
Code: Select all
Sub New()
        Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer, True)
        Me.SetStyle(ControlStyles.ResizeRedraw, True)
        Me.SetStyle(ControlStyles.DoubleBuffer, True)
        SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
        Font = New Font("Segoe UI", 9)
    End Sub
anyone has a new solution please?

Thanks

Re: Controls Flickering?

Posted: Sat Jan 07, 2017 3:57 pm
by CodenStuff
I think you may get flickering no matter what you do and it also depends on how powerful the users machine is to how much flickering they get and how long it takes to load.

You could try using SuspendLayout() and ResumeLayout() property
https://msdn.microsoft.com/en-us/librar ... .110).aspx

or

BeginUpdate() and EndUpdate()
https://msdn.microsoft.com/en-us/librar ... .110).aspx

Those may help a little.

Re: Controls Flickering?

Posted: Sat Jan 07, 2017 4:16 pm
by Dummy1912
Hi again,

Well this don't work
Code: Select all
Me.SuspendLayout()
and this
Code: Select all
 .BeginUpdate()
my controls don't has this option :(

any other ideas :)

Re: Controls Flickering?

Posted: Sun Jan 08, 2017 9:06 am
by Dummy1912
pfff what a night...

we have solved it
the flickering are less so its hard to tell :)
so happy

thanks codenstuff for the idea

solution:
added this on top of our class from the custom control
Code: Select all
    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or &H2000000
            Return cp
        End Get
    End Property