Flicker when form is maximized

Mar 27, 2011 at 5:29 AM

Hi There,

I am having an issue where the ribbon seems to flicker as it is displayed if the form window state is set to maximized by default.

The flicker does not occur if the state is normal.

This is quite ugly, and if you look at apps such as Wordpad or Paint on Win 7, you see that the very same ribbon framework does not have this flickering behaviour when their windows are opened as maximized....

Is there any way I can solve this?

 

Thanks!

Mar 29, 2011 at 7:33 AM

I cannot reproduce that with the sample applications. When I set the WindowState to Maximized and start the application for example 03-MenuDropDown the flicker does not occur.

 

Please, could you provide a sample?

Mar 29, 2011 at 4:10 PM

Weird - I managed to reproduce it with the sample applications also.

Unfortunately I can't provide a sample, however, I did create a blank application and set the window state to maximized... sure enough flicker occured.

Its quite subtle and you need to watch very closely for it, perhaps my eye is more sensitive.

Mar 30, 2011 at 4:01 PM
Edited Mar 31, 2011 at 6:05 AM

Ah, now I can see it. You mean the single flicker after startup. You are really having good eyes.

 

The reason is because the Ribbon is created during HandleCreated event of the Ribbon(Wrapper) control after the form.

 

I don’t know why it is happening only in WindowState-Maximized state. I think the Form implementation of .NET is doing something different here. Maybe the HandleCreated of the form and ribbon wrapper control is done in separate window messages.

 

I'm sorry, I don't have a working fix for this at the moment.

 

Mar 31, 2011 at 2:57 AM
Edited Mar 31, 2011 at 4:09 AM

Indeed i do mean the single flicker after start up.

 

"We can fix this as we create the ribbon during HandleCreated event of the form…"

Was that a tyo and should have been "can't fix this" or does the following code after that actually implement the fix?

Thanks for your help on this :)

Edit: With that code, you cant click the ribbon :( The Maximized state is really friggen annoying - its the reason I have to use Viewable = false, true ... to get everything to dock properly which causes more flicker!!

Your code FIXES the dock issue too! (But then you can't click the ribbon... why is there always a catch??)
Is then an entirely diffferent way that the ribbon can be initialized?

Mar 31, 2011 at 2:37 PM
Edited Mar 31, 2011 at 2:38 PM

Because the problem relies on the .NET Form implementation it is not posssible to fix this. But you can try the following workaround.

- Download the latest source from Source Code tab. Ribbon.cs now contains the new ViewCreated event, that will be raised after the ribbon is created by Ribbon Framework. You need to get the latest Ribbon.cs and RibbonUIApplication.cs

- Set the default WindowState of your Form to Minimized.

- Include the following code in your Form...

 

    public Form1()
        {
            InitializeComponent();

            this._ribbon.ViewCreated += new EventHandler(_ribbon_ViewCreated);
        }

        void _ribbon_ViewCreated(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }
Mar 31, 2011 at 2:47 PM

It works, but it breaks dynamic assigning of ribbon controls.

I.e. setting buttons to disabled stops working, and setting execute action event handlers don't fire.

I think I will just live with the flicker :)

Thanks for you help though.