MDI parent form background refresh issues

A

Andrus

I put picture and changed background color in MDI parent form.

There are refresh issues when child forms are created, moved, maximized and
restored:
Parts of background picture are incorrect.
Background contains parts of maximized child window.

I tested this in 2 different video cards in XP and Vista so this seems not a
video driver issue.

http://www.yoda.arachsys.com/csharp/faq contains note about this that Paint
event should be handled. Unfortunately it does not contain sample for this:
MDIControl is sealed, so it cannot be subclassed.

How to fix refresh issues ?

Andrus.
 
N

Nicholas Paldino [.NET/C# MVP]

Andrus,

Post a complete example, or at least show how you are setting the
picture and changing the background color on the MDI parent form.
 
A

Andrus

Post a complete example, or at least show how you are setting the
picture and changing the background color on the MDI parent form.

background color:

void MainForm_Load(object sender, System.EventArgs e) {
foreach (Control ctl in this.Controls) {
if (ctl is MdiClient) {
ctl.BackColor = System.Drawing.Color.White;
break;
}
}
}


background image is set in designer. Generated code:

//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImage = global::MyApp.Properties.Resources.mypicture;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.ClientSize = new System.Drawing.Size(644, 396);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.mainMenuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.IsMdiContainer = true;
this.KeyPreview = false;
this.MainMenuStrip = this.mainMenuStrip1;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
....

I can post complete example if you will look into it.

I posted on your request complete example about Virtual DataGridView column
resize hangup some month ago but havent got any reply.

Please re-confirm that you will look into the sample. I can create this
sample in this case because it requires a lot of work to extract code from
appl.

Andrus.
 
A

Andrus

I removed background picture and backgound color settings but the probme
persists:

I have mdi child form containing datagridview in maximized state.
If I open new MDI child form derived from the same class the following
happens:

1. Previous form is restored to normal state.
2. MDI parent form background is not re-painted fully: it contains parts of
maximized form.

If first child form is not maximized or if second form is created in
maximized state, this issue does not occur.

Questions:

1. Why previous form maximized state is lost.
2. How to forceMDI parent backgroud to paint correctly.

I tried to create simple repro but it works in this case. So there is
something specific in my application whicg causes this.

Andrus.
 

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