PC Review


Reply
Thread Tools Rate Thread

Resizing an MDI child withim the MDIParent.

 
 
=?Utf-8?B?QW1ub24gUmFwb3BvcnQ=?=
Guest
Posts: n/a
 
      20th Dec 2005
Hi. I have been trying unsuccessfully to resize an MDI child form to fit
exactly into the MDIParent and cover the whole of the ClientRectangle.
All code that I have written using the ClientRectangle shows the child form
as a bit to big and the MDI displayes scroll bars. .ClientSize.Width and
..ClientSize.height seem to return larger values than the Client area really
is.
Docking, which does give the correct result. is not an alternative as the
displayed child form cannot then be manipulated by the user to other
positions in the MDI client area.

Help would be appreciated.
 
Reply With Quote
 
 
 
 
Fox
Guest
Posts: n/a
 
      20th Dec 2005
Did you try to maximise your child form?


"Amnon Rapoport" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi. I have been trying unsuccessfully to resize an MDI child form to fit
> exactly into the MDIParent and cover the whole of the ClientRectangle.
> All code that I have written using the ClientRectangle shows the child
> form
> as a bit to big and the MDI displayes scroll bars. .ClientSize.Width and
> .ClientSize.height seem to return larger values than the Client area
> really
> is.
> Docking, which does give the correct result. is not an alternative as the
> displayed child form cannot then be manipulated by the user to other
> positions in the MDI client area.
>
> Help would be appreciated.



 
Reply With Quote
 
 
 
 
Bob Powell [MVP]
Guest
Posts: n/a
 
      20th Dec 2005
As well as Fox's recommendation you should also remember that the main form
is not actually the parent of the MDI child form. This role is undertaken by
the MDIClient which is owned by the main form. You should use this control
to provide information on main form areas etc.

There is an article in Windows Forms Tips and Tricks that explains how to
put a background on the MDIClient. This will show you how to obtain a
reference to that object.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Amnon Rapoport" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi. I have been trying unsuccessfully to resize an MDI child form to fit
> exactly into the MDIParent and cover the whole of the ClientRectangle.
> All code that I have written using the ClientRectangle shows the child
> form
> as a bit to big and the MDI displayes scroll bars. .ClientSize.Width and
> .ClientSize.height seem to return larger values than the Client area
> really
> is.
> Docking, which does give the correct result. is not an alternative as the
> displayed child form cannot then be manipulated by the user to other
> positions in the MDI client area.
>
> Help would be appreciated.



 
Reply With Quote
 
Amnon
Guest
Posts: n/a
 
      20th Dec 2005
Well, maximizing would be very much like using the Docking property.

The user would not be able to move the MDIChild around in the client area.

In VB6, the code is so trivial and it is causing me so much work in VS2005.

Very disheartening

Amnon


"Fox" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Did you try to maximise your child form?
>
>
> "Amnon Rapoport" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
>> Hi. I have been trying unsuccessfully to resize an MDI child form to fit
>> exactly into the MDIParent and cover the whole of the ClientRectangle.
>> All code that I have written using the ClientRectangle shows the child
>> form
>> as a bit to big and the MDI displayes scroll bars. .ClientSize.Width and
>> .ClientSize.height seem to return larger values than the Client area
>> really
>> is.
>> Docking, which does give the correct result. is not an alternative as the
>> displayed child form cannot then be manipulated by the user to other
>> positions in the MDI client area.
>>
>> Help would be appreciated.

>
>



 
Reply With Quote
 
Amnon
Guest
Posts: n/a
 
      20th Dec 2005
Well thank you Bob.

The whole MDI child resizing stuff has become a real nightmare.

I implemented parts of your code to get the right result ONCE. Then, if I
regenerated the same MDI child form, it seems that hidden mechanisms force
the second MDI client to be 'cascaded' relative to the visible 'child area'
of the MDI form. Do I have to look in the controls collection for the first
MDIClient by searching for its handle.

Then, what happens when I want a second different MDIChild form to be
generated. One on top of the other - not maximised and not 'docked'

How do I cancel the seeming default mechanism of the MDIParent to cascade
all subsequent instances IF this is indeed what is happening.

What a nightmare.

I would perhaps suggest that Microsoft does not want developers to use MDI
projects. Or at least in the way we used them in VB6.

I include the following code:

Public Function ReturnMDIClient(ByVal frm As System.Windows.Forms.Form) As
System.Windows.Forms.Control
Dim c As Control
For Each c In frm.Controls
If TypeOf c Is MdiClient Then
ReturnMDIClient = c
End If
Next c

End Function

AND

Dim frmBrowse As New Form1
Dim MDIClient As System.Windows.Forms.Control

MDIClient = ReturnMDIClient(frmMain)
frmBrowse.MdiParent = frmMain
frmBrowse.Left = 0 'MDIClient.Left
frmBrowse.Top = 0 'MDIClient.Top
frmBrowse.Width = MDIClient.Width - 5
frmBrowse.Height = MDIClient.Height - 5
frmBrowse.Show()

The first time that the MDIChild was generated, it fitted nicely into the
client area but the second time with the same instance of the frmMain, the
..top and .left values were displaced as if it were cascaded relative to the
first.

I tried to send this email with a screen shot of the cascading effect BUT
there was an error

Awaiting your comments

Amnon

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:(E-Mail Removed)...
> As well as Fox's recommendation you should also remember that the main
> form
> is not actually the parent of the MDI child form. This role is undertaken
> by
> the MDIClient which is owned by the main form. You should use this control
> to provide information on main form areas etc.
>
> There is an article in Windows Forms Tips and Tricks that explains how to
> put a background on the MDIClient. This will show you how to obtain a
> reference to that object.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "Amnon Rapoport" <(E-Mail Removed)> wrote in
> message
> news:(E-Mail Removed)...
>> Hi. I have been trying unsuccessfully to resize an MDI child form to fit
>> exactly into the MDIParent and cover the whole of the ClientRectangle.
>> All code that I have written using the ClientRectangle shows the child
>> form
>> as a bit to big and the MDI displayes scroll bars. .ClientSize.Width and
>> .ClientSize.height seem to return larger values than the Client area
>> really
>> is.
>> Docking, which does give the correct result. is not an alternative as the
>> displayed child form cannot then be manipulated by the user to other
>> positions in the MDI client area.
>>
>> Help would be appreciated.

>
>




 
Reply With Quote
 
Martin Stainsby
Guest
Posts: n/a
 
      20th Dec 2005

"Amnon" <(E-Mail Removed)> wrote in message
news:OaLLh$(E-Mail Removed)...
> Well thank you Bob.
>
> The first time that the MDIChild was generated, it fitted nicely into the
> client area but the second time with the same instance of the frmMain, the
> .top and .left values were displaced as if it were cascaded relative to
> the
> first.


Try setting the MDIChild's StartPosition to manual.


 
Reply With Quote
 
Amnon
Guest
Posts: n/a
 
      21st Dec 2005
Thank you Martin.

That did the job

Amnon


"Martin Stainsby" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Amnon" <(E-Mail Removed)> wrote in message
> news:OaLLh$(E-Mail Removed)...
>> Well thank you Bob.
>>
>> The first time that the MDIChild was generated, it fitted nicely into the
>> client area but the second time with the same instance of the frmMain,
>> the
>> .top and .left values were displaced as if it were cascaded relative to
>> the
>> first.

>
> Try setting the MDIChild's StartPosition to manual.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI question - how to call other MDI child forms from a MDI chilid form? Robert Johnson Microsoft VB .NET 2 21st Jun 2007 11:27 PM
How to open MDI Child from within another MDI Child? =?Utf-8?B?a3ZyZGV2MQ==?= Microsoft Dot NET 0 31st Mar 2005 08:09 PM
MDI - how to open a child from a child within MDI parent? Marina Neyman Microsoft Dot NET Framework Forms 1 7th Feb 2004 08:12 PM
MDI - how to open a child from a child within MDI parent form? Marina Neyman Microsoft Dot NET Framework Forms 0 7th Feb 2004 02:27 AM
A problem to opem MDI child form from another MDI child form Herfried K. Wagner [MVP] Microsoft VB .NET 2 26th Dec 2003 10:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 PM.