Peter said:
I don't know that much about MDI applications, but I have no trouble at
all setting a centered background image, with or without the form having
its IsMdiContainer property set to "true". The image redraws reliably
as I resize the form. As long as the form's not an MDI container, I can
even easily get rid of the flickering just by setting the DoubleBuffered
property to "true" in the form constructor.
Making the form an MDI container does cause the background color to be
ignored. That is, it's still drawn, but then the MDI window class stuff
kicks in and covers it up with the MDI background color. But the image
itself is drawn fine.
So, if you're having trouble, it's either because you're doing something
more complicated than just making the form an MDI container, or it's
because you're using an older version of .NET in which there are
problems that don't exist on the latest version.
Without a concise-but-complete code sample from you, that reliably
demonstrates the problem, I don't think there's much else to offer in
the way of advice.
Pete
Well here it goes.
I only have the main form isMdiContainer = true (design time).
I have a toolbar+main menu (dock=Top) and a status bar (dock=bottom).
I set the background color to Black on the form, set my background image
that is black on the edges (from within a resource though i dont know if
it matters) and whenever i resize the form nothing happens. I mean the
image stays exactly where it was first drawn. It is redrawn only if i
pass another windows above it or drag the main window out of the desktop
and back in again (i.e. force it to redraw). At the moment i put a
Refresh() inside the OnResize of the main form and with DoubleBuffered
ON only the image seems to flicker somewhat. Guess i will stay with
that. I am using VS2008 SP1, i think it is the latest release since
microsoft update seems to not being able to find any update for VS at
the moment at least.
designer code...
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.BackColor = System.Drawing.Color.Black;
this.BackgroundImage = global::TestPrj.Properties.Resources.bgimg;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.DoubleBuffered = true;
this.IsMdiContainer = true;
I noticed that there is also
this.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
public void frmMain_Layout(object sender, LayoutEventArgs e)
{
try
{
if (clsVariables.m_bLayoutCalled == false)
{
clsVariables.m_bLayoutCalled = true;
clsVariables.m_dt = DateTime.Now;
if (frmSplashScreen.SplashForm != null)
frmSplashScreen.SplashForm.Owner = this;
this.Activate();
frmSplashScreen.CloseForm();
}
}
catch
{
//
}
//base.PerformLayout();
}
I Added the base.PerformLayout(); but it does not seem to do anything
whatsoever. Dont know if the above code affects the image rendering though.
I would appreciate any help,
Jim