MDI Client Repaint

G

Guest

Hi,
I have created a MDI Form with the formborderstyle = NONE so that it
does not display any title bar and control buttons. This MDI form host a
child form with the same attibutes ( i.e formborderstyle = NONE ). The MDI
form contains set of buttons. On pressing each button a new child form is
created and previously displayed form is closed. When a transition happens
from one form to another, there is flicker. This flicker happens because the
title and the border of the child form is displayed for a moment which should
not be shown.
Has anyone got suggestions as to how to avoid this flickering problem
during the repainting of child forms so that the title and the border are not
displayed.
 
G

Guest

try use doble buffer in mdi
Public Sub New()
MyBase.New()
'El Diseñador de Windows Forms requiere esta llamada.
InitializeComponent()
'Agregar cualquier inicialización después de la llamada a
InitializeComponent()
Me.SetStyle(ControlStyles.DoubleBuffer And ControlStyles.UserPaint And
ControlStyles.AllPaintingInWmPaint, True)
Me.UpdateStyles()
 
G

Guest

I have already used in this setting in the MDI Client. I also tried
overriding the WM_PAINT message since I happened to read that MDIClient does
not support double buffering like the way you have suggested. But still the
problem persists.

thanks
 
G

Guest

Have a lot of controls the mdi forms?
Can you write a piece of code to show the issue?
 
G

Guest

Public class MDIClientForm
{

public MDIClientForm()
{
//for double buffering
this.SetStyle( ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
this.UpdateStyles();
}

private but1_click(object sender, EventArgs e)
{
CloseDisplayedForm();
Form frm1 = new Form
frm1.MdiParent = this;
frm1.Show();
}

private but2_click(object sender, EventArgs e)
{
CloseDisplayedForm();
Form frm2 = new Form
frm2.MdiParent = this;
frm2.Show();
}

}

So when i switch between the 2 forms pressing the button present on the
MDIClient form, I see the flickering happening which forms are being painted.

thanks
 
L

Lloyd Dupont

I had flickering issue with windows as well (but not in the MDI context,
though..)

I could suggest this 2 thing:
- use Hide() 1st, then Close()
- set Opacity=0, then Close()
 
G

Guest

This is a confirmed Microsoft problem. I had a long discussion with Jeffry
Tan of MS on the managed site about this.

There are a couple of things you can do about reducing the flicker but it
can't be eliminated (that is until MS fixes the problem). Also, you will find
that the form is sometimes displayed in the wrong place (i.e., iif it is
centered it won't be) Here is what I do to reduce the flicker and positioning
problem.

Set FormBorderStyle to None. Set form.dock = dockstyle.fill
Also I add a MyShow Sub and a form_Activated Sub.
Before switching forms I hide the current form and call form.MyShow. Since I
hide the form form_Load only is executed once. form.MyShow usually is just
form.Show but could have some code to handle another MS problem (formA calls
formB, FormB returns to FormA, FormA automatically call FormC without any
user interaction. If FormA is shown then FormC is never displayed. I put code
in MyShow to handle this problem. That is switch to FormC without displaying
FormA).

form_Activated has any code that is needed to initialize the form based on
what form called it and previous history.

Hope that helps.
 
G

Guest

One other thing. If your form does a lot of processing when it is displayed
the flicker will be more apparent. I set up a timer with a .1 sec interval.
When the timer expires I start the processing.
 
L

Lloyd Dupont

have you try to set windows opacity to 0 before closing it?
I'll bet it will work!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top