Domanda

I am using a library in which enables me to animate movement of WinForm elements (linked below), when I use it to move a transparent panel across the form (which has a picture background) there is an extraordinary amount of tearing.

I believe the fix is to get winforms to refresh at a rate of 30fps without being laggy. I tried settings a timer to do This.Refresh(); at 30 times a second but it just ended up with slow loading. So how would I achieve a nice refresh rate of the form?

The link described above is here -> http://code.google.com/p/dot-net-transitions/wiki/CodingWithTransitions#Creating_a_transition_that_works_on_a_single_property

Here is an example of the tearing. It might have something to do with the fact that the panel's backcolor is set to "transparent" http://screencast.com/t/XIr3NkGI

È stato utile?

Soluzione

I used this ages ago when I had trouble with controls on a form flickering, in my case there were many controls and when loading the form the controls would flicker quite badly.

In the end I used this:

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x02000000;
            return cp;
        }
    }

Paste that in your form.

It activates double buffering at the form level and for all controls within it. HOWEVER, while it stopped my flickering issue it greatly reduced the speed at which the forms elements seemed to move as they don't get drawn until they are 100% ready.

I guess you can try and see if it suits your situation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top