MDI ClientSize 
Author Message
 MDI ClientSize

I've been struggling with this on and off for a week. The scenario:

1. Create a form and make it an MDI [IsMdiContainer=True]

2. Place two panels on the MDI form. Align one to the top and the other to
the bottom.

3. Create one MDI Child Form [frmChild]. Use the following in the MDI form
to load the Child:

Private Sub LoadAChildForm()

Dim frm As Form

frm = New frmChild()

With frm

.MdiParent = Me

.Show()

End With

End Sub

4. Center the form in the MDI Client Area using something like:

Public Sub CenterFormInMDI(ByVal mdi As Form, ByVal frm As Form)

Dim l As Integer, t As Integer

With frm

l = (mdi.ClientSize.Width - .Width) \ 2

t = (mdi.ClientSize.Height - .Height) \ 2

.SetBounds(l, t, .Width, .Height)

End With

End Sub

5. The form will not be centered in the MDI because 'ClientSize' is not
returning the correct internal client area size.

Is there another way to get the size of the Client area?  How can I center
the form in the client area of the MDI?

Cheers,
Larry Rebich



Sun, 14 Nov 2004 21:50:58 GMT  
 MDI ClientSize
Just wondering, before going through all these pains, did
you try the startposition property of the form??

Quote:
>-----Original Message-----
>I've been struggling with this on and off for a week. The
scenario:

>1. Create a form and make it an MDI [IsMdiContainer=True]

>2. Place two panels on the MDI form. Align one to the top
and the other to
>the bottom.

>3. Create one MDI Child Form [frmChild]. Use the

following in the MDI form
Quote:
>to load the Child:

>Private Sub LoadAChildForm()

>Dim frm As Form

>frm = New frmChild()

>With frm

>..MdiParent = Me

>..Show()

>End With

>End Sub

>4. Center the form in the MDI Client Area using something
like:

>Public Sub CenterFormInMDI(ByVal mdi As Form, ByVal frm
As Form)

>Dim l As Integer, t As Integer

>With frm

>l = (mdi.ClientSize.Width - .Width) \ 2

>t = (mdi.ClientSize.Height - .Height) \ 2

>..SetBounds(l, t, .Width, .Height)

>End With

>End Sub

>5. The form will not be centered in the MDI

because 'ClientSize' is not

- Show quoted text -

Quote:
>returning the correct internal client area size.

>Is there another way to get the size of the Client area?  
How can I center
>the form in the client area of the MDI?

>Cheers,
>Larry Rebich

>.



Sun, 14 Nov 2004 23:31:03 GMT  
 MDI ClientSize
I know about the 'StartPosition'. I want to center the form in the MDI's
client area AFTER it is loaded. I don't think there is a way to force the
form into its start position AFTER it is loaded without using SetBounds.

In VB6 the MDI's scalewidth and scaleheight could be used to center the form
in the MDI's client area. Scalewidth and scaleheight excluded aligned
[docked] controls such as a picture boxes. And we could do something like:

With frmMyChildForm
 .Move (frmMDI.ScaleWidth - .Width)\2, (frmMDI.ScaleHeight - .Height)\2
End With

Cheers,
Larry Rebich


Quote:
> Just wondering, before going through all these pains, did
> you try the startposition property of the form??

> >-----Original Message-----
> >I've been struggling with this on and off for a week. The
> scenario:

> >1. Create a form and make it an MDI [IsMdiContainer=True]

> >2. Place two panels on the MDI form. Align one to the top
> and the other to
> >the bottom.

> >3. Create one MDI Child Form [frmChild]. Use the
> following in the MDI form
> >to load the Child:

> >Private Sub LoadAChildForm()

> >Dim frm As Form

> >frm = New frmChild()

> >With frm

> >..MdiParent = Me

> >..Show()

> >End With

> >End Sub

> >4. Center the form in the MDI Client Area using something
> like:

> >Public Sub CenterFormInMDI(ByVal mdi As Form, ByVal frm
> As Form)

> >Dim l As Integer, t As Integer

> >With frm

> >l = (mdi.ClientSize.Width - .Width) \ 2

> >t = (mdi.ClientSize.Height - .Height) \ 2

> >..SetBounds(l, t, .Width, .Height)

> >End With

> >End Sub

> >5. The form will not be centered in the MDI
> because 'ClientSize' is not
> >returning the correct internal client area size.

> >Is there another way to get the size of the Client area?
> How can I center
> >the form in the client area of the MDI?

> >Cheers,
> >Larry Rebich

> >.



Mon, 15 Nov 2004 01:53:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. BUG: MDI ClientSize fails to update on docked control resize

2. newbie question: why does ClientSize hide?

3. MDI problem, com MDI to MDI-child

4. MDI problem, com MDI to MDI-child

5. MDI problem, com MDI to MDI child

6. Modifying object in MDI Parent form from MDI Child form

7. Non-MDI form to MDI form

8. Make a reference to a MDI form with a reference of a MDI child form

9. Q: Form activate Fires On Non Child MDI Forms But Only Once On Child Mdi Forms

10. MDI interface without a MDI form?

11. Maximized MDI child form Covering Status bar on MDI parent

12. How do you center MDI and MDI Child with 1 chunk of code

 

 
Powered by phpBB® Forum Software