0

I'm writing a "multi-screened" application in C#. The "screens" represent different areas of the program i.e. Settings, Restricted Access, Administration, etc.

The problem I'm having is when I'm transitioning between one panel and another. During the transition process, the whole form momentarily glitches and the outlines of some of the controls can be seen. Any text on the panels appears as a block with the background of the other panel and other weird things occur.

Here's some screenshots of what I'm trying to explain...

Here's what the panel I'm transitioning to SHOULD look like:

enter image description here

and here's what happens in the transitioning process:

enter image description here

I have a function that I use to transition between the panels. The code is as follows:

delegate void DtransPanel(object pan1, object pan2);
    private void transPanel(object hide, object show)
    {
        if (InvokeRequired) Invoke(new DtransPanel(transPanel), new object[] { hide, show });
        else
        {
            Panel h = (Panel)hide;
            Panel s = (Panel)show;
            h.Hide();
            Application.DoEvents();
            s.Show();
        }
    }

I'm a complete novice when it comes to graphics and such-like. There is probably a better method than using the function above :P

My apologies if there is a similar question that I haven't found (I did search around) or if I've made the noobiest mistake on the planet...

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
JJC
  • 25
  • 1
  • 1
  • 3
  • 1
    I Strongly recommend WPF instead of winforms for almost anything. You will not have these issues because of the DirectX-based hardware acceleration. BTW you could use the [WPF Bag of Tricks](https://github.com/thinkpixellab/bot) which includes a `TransitionPresenter`, which supports dozens of different animated transitions. [here](http://www.youtube.com/watch?v=q60fF2rZUiU) are some examples of those transitions. – Federico Berasategui Aug 09 '13 at 02:05
  • Sometimes I am calling from a different thread, but predominantly from the main application thread – JJC Aug 15 '13 at 22:05

1 Answers1

0

You could try using:

Panel h = (Panel)hide;
Panel s = (Panel)show;
h.Hide();
s.SuspendLayout();
s.Show();
s.ResumeLayout();

This should mean that you won't see the

Shane Haw
  • 723
  • 9
  • 22