sizing mdi child

R

Rainer Queck

Hi NG,

how can I size a mdi child to that it fits exactliy into "available" client
rectangle of a mdi container without setting its WindowState to Maximized?

On my MDI main form I have a ToolStrip docked to the right, which
dynamically changes its width.
I tried:
myForm.Width = this.ClientRectangle.Widht;
but then my form is wider then tha clientrectangle and the "close" button of
the form is not visible any more.
Next I tried :
myForm.Width = this.ClientRectangle.Widht - myToolStrip.Width;
still my form is wider then the remaining (client rect width - toolstrip
width) area.
By "try and error" I found that I get the wanted result by:
myForm.Width = this.ClientRectangle.Widht - myToolStrip.Width - 25;

But this can't be the only way to do it. I am sure there is a more
professional way to get what I want, right?

Thanks for hints and help
Rainer Queck
 
G

Guest

You might be probably looking for these:
this.LayoutMdi( MdiLayout.TileHorizontal );
this.LayoutMdi( MdiLayout.TileVertical );
 
R

Rainer Queck

Hi Farshad,

farshad.A said:
You might be probably looking for these:
this.LayoutMdi( MdiLayout.TileHorizontal );
this.LayoutMdi( MdiLayout.TileVertical );

thanks for answering.
No that is not what I was looking for.
Acutally I found the reason to my problem:
I addusted "myForm.Width = this.ClientRectangle.Widht;" and then added the
toolstripbutton.
Doing it vice versa solved my problelm ;-)

Regards
Rainer
 
J

Jeffrey Tan[MSFT]

Hi Rainer ,

Glad to see your found the problem yourself. Also thank you for sharing the
result with the community!

I am curious to know why you do not want to use this.LayoutMdi() method.
Based on my test, if I place a ToolStrip docking to right, and use
LayoutMdi method to perform the layout, it seems that this will force the
child form to overlay the entire client area without maximized:

private void Form1_Load(object sender, EventArgs e)
{
Form f = new Form();
f.MdiParent = this;
f.Show();
}

private void button1_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);
}
I feel this easier than calculating the size and position ourselves. Is
there any special reason to not use this? Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Rainer Queck

Hi Jeffrey,

I am curious to know why you do not want to use this.LayoutMdi() method.
Based on my test, if I place a ToolStrip docking to right, and use
LayoutMdi method to perform the layout, it seems that this will force the
child form to overlay the entire client area without maximized:

private void Form1_Load(object sender, EventArgs e)
{
Form f = new Form();
f.MdiParent = this;
f.Show();
}

private void button1_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);
}
I feel this easier than calculating the size and position ourselves. Is
there any special reason to not use this? Thanks!
The reason why is, that in my case there mostly are other mdichilderen
already existing.
If I use this.LayoutMdi() all children have to share the available space,
but what I want is, that the new created child gets to use the whole space,
without maixmizing.

By the way ...
I am using LayoutMdi() but under different conditions.

Regards
Rainer
 
J

Jeffrey Tan[MSFT]

Hi Rainer,

Got it. Then we have to calculate the child window size manually as what
you have done :) Thanks for your clarify.

If you need further help, please feel free to post. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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