Parent Window

  • Thread starter Thread starter DaveL
  • Start date Start date
D

DaveL

i Want to set Color Back ground for a
Application Mdi Window (parent)

i set the form.IsMdiContainer=true;

and i can't Change colors of the main window
is there a way to do this

Thanks
Dave
 
Nevermind got it working
thanks below code to color and draw center text
and footer text

private void ShellWindow_Paint(object sender, PaintEventArgs e)
{

MdiClient oWin = null;
// get the midi frame control
for (int tt = 0; tt < this.Controls.Count; tt++)
{
if (this.Controls[tt] is MdiClient)
{
oWin = (MdiClient)this.Controls[tt];
// break;
}

}


Graphics oGraphics = oWin.CreateGraphics();

oWin.BackColor = System.Drawing.Color.Blue ; //.RoyalBlue;
//.FromArgb(35,7,143); //.Brushes.AliceBlue;
oWin.Refresh();
// Create string to draw.
//e.MeasureString(drawString, this.Font);
// Create font and brush.
Font oFont = new System.Drawing.Font("Arial Wide", 30,
FontStyle.Bold | FontStyle.Italic);
System.Drawing.SizeF TxtSize = oGraphics.MeasureString(Header,
oFont);
SolidBrush GreyBrush = new
SolidBrush(System.Drawing.Color.Black);
SolidBrush BlackBrush = new
SolidBrush(System.Drawing.Color.White);
// Create point for upper-left corner of drawing.
//x=widht
//y=height

float x = (this.ClientSize.Width / 2) - (TxtSize.Width / 2);
float y = (this.ClientSize.Height / 2) - (TxtSize.Height / 2);
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags =
StringFormatFlags.MeasureTrailingSpaces;
//draw Shadow
oGraphics.DrawString(Header, oFont, GreyBrush, x + 3, y + 3,
drawFormat);
// Draw string to screen.

oGraphics.DrawString(Header, oFont, BlackBrush, x, y,
drawFormat);
//draw Owner Notice bottom Right

oFont = new Font("Arial Wide", 10, FontStyle.Bold |
FontStyle.Underline); // FontStyle.Underline);


TxtSize = oGraphics.MeasureString(Footer, oFont);
oGraphics.DrawString(Footer, oFont, BlackBrush,
oWin.ClientSize.Width - TxtSize.Width,
oWin.ClientSize.Height
- TxtSize.Height, drawFormat);
}


private void Form1_Resize(object sender, EventArgs e)
{
//force a Repaint for color and Text to be re aligned
this.Invalidate();
}
 

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

Back
Top