5 Replies - 3386 Views - Last Post: 25 October 2019 - 01:19 PM Rate Topic: -----

#1 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Open new form causing flicker

Posted 14 March 2014 - 05:21 AM

Hi folks


I have a windows form application which has many 5 main forms, rest of the forms act like popups

The issue im having is when i open a new form, say for instance im on the main form and i want to hide this and open a new form. When this occurs i get a quick flicker where the desktop is displayed for a millisecond.

My application theme is dark and ususlly IE is open (white) so i see a white flicker

Very annoying

when i execute my code i always display the new form first then hide the old form.

ie
form2.show()
form1.hide()



to attempt to rectify this issue i tried loading the main form with split containers. This works however it is completely unmanagable with many forms

So my question is, what is the best approach to hiding / showing forms or the best approach to developing systems with many forms

I cant imagine that i should be creating the controls at runtime via code and using one form :(/>

thanks for any advice

This post has been edited by deery5000: 14 March 2014 - 05:24 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Open new form causing flicker

#2 belgarion262   User is offline

  • Prince of all (2) Saiyans

Reputation: 172
  • View blog
  • Posts: 955
  • Joined: 25-October 09

Re: Open new form causing flicker

Posted 14 March 2014 - 05:47 AM

By default, .NET forms refresh the background each time a new control becomes visible. If the form has many controls and/or 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:

'PREVENT FLICKERING 
    Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or 33554432
            Return cp
        End Get
    End Property
    Private Sub PreVentFlicker()
        With Me
            .SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
            .SetStyle(ControlStyles.UserPaint, True)
            .SetStyle(ControlStyles.AllPaintingInWmPaint, True)
            .UpdateStyles()
        End With

    End Sub

This post has been edited by belgarion262: 14 March 2014 - 05:49 AM

Was This Post Helpful? 0
  • +
  • -

#3 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: Open new form causing flicker

Posted 16 March 2014 - 03:43 PM

You have posted my code from another thread lol

I do mot have problems with flickering of controls with transparent backgrounds.

The issue is when i show a new form , looks like tge previous form is closed before showing the next however yo code shows the new form first tgen hides the old one.

Any orther ideas
Was This Post Helpful? 0
  • +
  • -

#4 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: Open new form causing flicker

Posted 18 March 2014 - 03:38 AM

SOLVED

When load and hide forms like this:

Form2.show()
me.hide()



This can cause the desktop to be displayed for a quick millisecond (causing and quick flick)

However if you show form2 then hide the previous form onload there will be no flick.

Hope this helps someone :)
Was This Post Helpful? 0
  • +
  • -

#5 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: Open new form causing flicker

Posted 28 March 2014 - 03:37 AM

Still happening!

this is very odd, if i open form 2 and at the end of the onload(form2) i hide form(1) there is still a quick flash of the desktop.

Anyone else seen this before?
Was This Post Helpful? 0
  • +
  • -

#6 DavidRizzo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-October 19

Re: Open new form causing flicker

Posted 25 October 2019 - 01:19 PM

View Postdeery5000, on 28 March 2014 - 03:37 AM, said:

Still happening!

this is very odd, if i open form 2 and at the end of the onload(form2) i hide form(1) there is still a quick flash of the desktop.

Anyone else seen this before?



Yes, I know exactly what you mean, having the same issue, did you ever find a resolution?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1