469,945 Members | 1,762 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Center in Child

vul
I have an MDI application with a ListBar on the left side of MDI form. All
child forms are displayed inside of the client area of MDI form.
Now I need to display a third form from a child and center it related to the
calling Child form. I cannot find the way to do that.

Any help please
Al
Apr 10 '06 #1
5 4316
What if you set the owner or parent property of the subchild form to the
childform?

"vul" <aa*@optonline.net> wrote in message
news:Oc**************@TK2MSFTNGP04.phx.gbl...
I have an MDI application with a ListBar on the left side of MDI form. All
child forms are displayed inside of the client area of MDI form.
Now I need to display a third form from a child and center it related to
the calling Child form. I cannot find the way to do that.

Any help please
Al

Apr 10 '06 #2
Al
I tried to set
Me.Parent = Supplier (Supplier is a caller form) and got an error:
Top-level control cannot be added to a control.

ParentForm property is ReadOnly, so I cannot use it.
Then I tried
Me.Owner = Supplier

It doesn't center the third form in the calling one. It centers in MDI

Thank you

Al

"SStory" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
What if you set the owner or parent property of the subchild form to the
childform?

"vul" <aa*@optonline.net> wrote in message
news:Oc**************@TK2MSFTNGP04.phx.gbl...
I have an MDI application with a ListBar on the left side of MDI form. All
child forms are displayed inside of the client area of MDI form.
Now I need to display a third form from a child and center it related to
the calling Child form. I cannot find the way to do that.

Any help please
Al


Apr 10 '06 #3
hi Al,

try these and let me know:

'SOLUTION 1:
'ChildOfMDIChild is owned MDIChild: stays on top
'of it and moves independently

Dim ChildOfMDIChild1 As New Form
With ChildOfMDIChild1
.Owner = Me
.StartPosition = FormStartPosition.Manual
.Location = New Point(.Owner.Left + (.Owner.Width - .Width)
\ 2, _
.Owner.Top + (.Owner.Height -
..Height) \ 2)
.Show()
End With
'SOLUTION 2:
'ChildOfMDIChild is within MDIChild and moves with it
'cannot exit from MDIChild (behaves somehow like a control)

Dim ChildOfMDIChild2 As New Form
With ChildOfMDIChild2
.TopLevel = False
.Parent = Me
.Location = New Point((.Parent.Width - .Width) \ 2, _
(.Parent.Height - .Height) \ 2)
.Show()
End With

-tom
Al ha scritto:
I tried to set
Me.Parent = Supplier (Supplier is a caller form) and got an error:
Top-level control cannot be added to a control.

ParentForm property is ReadOnly, so I cannot use it.
Then I tried
Me.Owner = Supplier

It doesn't center the third form in the calling one. It centers in MDI

Thank you

Al

"SStory" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
What if you set the owner or parent property of the subchild form to the
childform?

"vul" <aa*@optonline.net> wrote in message
news:Oc**************@TK2MSFTNGP04.phx.gbl...
I have an MDI application with a ListBar on the left side of MDI form. All
child forms are displayed inside of the client area of MDI form.
Now I need to display a third form from a child and center it related to
the calling Child form. I cannot find the way to do that.

Any help please
Al



Apr 10 '06 #4
Al
Thanbk you Tom
No success.
First solution centers the third form inside of MDI, not the child who calls
a third form. It's because the child has Location 0,0 within MDI, but as I
said in my initial post, there is a List Bar on the left side in MDI.

The second solution doesn't work too by many reasons.
My third form must be modal, and I use ShowDialog. ShowDialog is not allowed
for not top level forms, if I try to use Show, the form just doesn't appear.
I don't know why.

I was hoping that there is a simple solution, like the change one or 2
settings. I've been thinking about calculation for Location of the third
form, but decided to look for a more elegant solution.
At least temporarily I'll use your approach - I'll calculate Location for
the third form.

Thank you
Al
<to**************@uniroma1.it> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
hi Al,

try these and let me know:

'SOLUTION 1:
'ChildOfMDIChild is owned MDIChild: stays on top
'of it and moves independently

Dim ChildOfMDIChild1 As New Form
With ChildOfMDIChild1
.Owner = Me
.StartPosition = FormStartPosition.Manual
.Location = New Point(.Owner.Left + (.Owner.Width - .Width)
\ 2, _
.Owner.Top + (.Owner.Height -
.Height) \ 2)
.Show()
End With
'SOLUTION 2:
'ChildOfMDIChild is within MDIChild and moves with it
'cannot exit from MDIChild (behaves somehow like a control)

Dim ChildOfMDIChild2 As New Form
With ChildOfMDIChild2
.TopLevel = False
.Parent = Me
.Location = New Point((.Parent.Width - .Width) \ 2, _
(.Parent.Height - .Height) \ 2)
.Show()
End With

-tom
Al ha scritto:
I tried to set
Me.Parent = Supplier (Supplier is a caller form) and got an error:
Top-level control cannot be added to a control.

ParentForm property is ReadOnly, so I cannot use it.
Then I tried
Me.Owner = Supplier

It doesn't center the third form in the calling one. It centers in MDI

Thank you

Al

"SStory" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
> What if you set the owner or parent property of the subchild form to
> the
> childform?
>
> "vul" <aa*@optonline.net> wrote in message
> news:Oc**************@TK2MSFTNGP04.phx.gbl...
>>I have an MDI application with a ListBar on the left side of MDI form.
>>All
>>child forms are displayed inside of the client area of MDI form.
>> Now I need to display a third form from a child and center it related
>> to
>> the calling Child form. I cannot find the way to do that.
>>
>> Any help please
>> Al
>>
>>
>
>

Apr 11 '06 #5

Well ... that's really strange. I jave just retried it on my pc (using
vb2003) and the first solution centers the third form inside its owner,
not the MDI form, like you report (?). If I move the child the form and
open the form, it is always centered within the MDI child.

Are you sure you have pasted exactly the same code. Note that is
important the sequence of statements and .StartPosition =
FormStartPosition.Manual...

- tom

Al ha scritto:
Thanbk you Tom
No success.
First solution centers the third form inside of MDI, not the child who calls
a third form. It's because the child has Location 0,0 within MDI, but as I
said in my initial post, there is a List Bar on the left side in MDI.

The second solution doesn't work too by many reasons.
My third form must be modal, and I use ShowDialog. ShowDialog is not allowed
for not top level forms, if I try to use Show, the form just doesn't appear.
I don't know why.

I was hoping that there is a simple solution, like the change one or 2
settings. I've been thinking about calculation for Location of the third
form, but decided to look for a more elegant solution.
At least temporarily I'll use your approach - I'll calculate Location for
the third form.

Thank you
Al
<to**************@uniroma1.it> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
hi Al,

try these and let me know:

'SOLUTION 1:
'ChildOfMDIChild is owned MDIChild: stays on top
'of it and moves independently

Dim ChildOfMDIChild1 As New Form
With ChildOfMDIChild1
.Owner = Me
.StartPosition = FormStartPosition.Manual
.Location = New Point(.Owner.Left + (.Owner.Width - .Width)
\ 2, _
.Owner.Top + (.Owner.Height -
.Height) \ 2)
.Show()
End With
'SOLUTION 2:
'ChildOfMDIChild is within MDIChild and moves with it
'cannot exit from MDIChild (behaves somehow like a control)

Dim ChildOfMDIChild2 As New Form
With ChildOfMDIChild2
.TopLevel = False
.Parent = Me
.Location = New Point((.Parent.Width - .Width) \ 2, _
(.Parent.Height - .Height) \ 2)
.Show()
End With

-tom
Al ha scritto:
I tried to set
Me.Parent = Supplier (Supplier is a caller form) and got an error:
Top-level control cannot be added to a control.

ParentForm property is ReadOnly, so I cannot use it.
Then I tried
Me.Owner = Supplier

It doesn't center the third form in the calling one. It centers in MDI

Thank you

Al

"SStory" <no****@nospam.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
> What if you set the owner or parent property of the subchild form to
> the
> childform?
>
> "vul" <aa*@optonline.net> wrote in message
> news:Oc**************@TK2MSFTNGP04.phx.gbl...
>>I have an MDI application with a ListBar on the left side of MDI form.
>>All
>>child forms are displayed inside of the client area of MDI form.
>> Now I need to display a third form from a child and center it related
>> to
>> the calling Child form. I cannot find the way to do that.
>>
>> Any help please
>> Al
>>
>>
>
>


Apr 11 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by FL | last post: by
3 posts views Thread by Zack Sessions | last post: by
reply views Thread by Innova | last post: by
1 post views Thread by Brett Romero | last post: by
1 post views Thread by Brett Romero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.