473,474 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MDI Child start position

Hi

Why is my mdichild form not starting in the "centerparent" position? I'm
using the following:

Public Class frmCAD
Private Sub MakeNewCallToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MakeNewCallToolStripMenuItem.Click
Dim frmNew As New frmMakeNewCall()
frmNew.MdiParent = Me
frmNew.StartPosition = FormStartPosition.CenterParent
frmNew.Show()
End Sub
End Class

Thanks

Michael Bond
Oct 9 '06 #1
3 8470
MDI children ignore the StartPosition property, as well as any other
attempt to set their position prior to .Show.

Put this in the Load event of every MDI child form you want centered:

CenterInParent(Me)

And this in a module:

Sub CenterInParent(ByRef frm As Object)
frm.Left = Higher((frm.Parent.ClientSize.Width - frm.Width) / 2, 0)
frm.Top = Higher((frm.Parent.ClientSize.Height - frm.Height) / 2,
0)
End Sub

Function Higher(ByRef x, ByRef y)
Higher = IIf(x y, x, y)
End Function

Oct 10 '06 #2
Hi

thanks for that.......

suppose I shouldn't ask, but if the MDI children ignore the StartPosition
property why provide a "centreparent" option for the startposition ????.
Answers on a postcard to Microsoft.com please

Thanks again

Michael


"te******@hotmail.com" wrote:
MDI children ignore the StartPosition property, as well as any other
attempt to set their position prior to .Show.

Put this in the Load event of every MDI child form you want centered:

CenterInParent(Me)

And this in a module:

Sub CenterInParent(ByRef frm As Object)
frm.Left = Higher((frm.Parent.ClientSize.Width - frm.Width) / 2, 0)
frm.Top = Higher((frm.Parent.ClientSize.Height - frm.Height) / 2,
0)
End Sub

Function Higher(ByRef x, ByRef y)
Higher = IIf(x y, x, y)
End Function

Oct 10 '06 #3
Can I just ask in addition to this, I would like to remember the previous
location of the window on the MDI parent for the child form. I can do this.
However, when displaying the window opens at its original location then
moves. Is there anyway to do this (perhaps using API calls or something) that
can move a window on it's initial display without flickering it?

Thanks
Mike

"te******@hotmail.com" wrote:
MDI children ignore the StartPosition property, as well as any other
attempt to set their position prior to .Show.

Put this in the Load event of every MDI child form you want centered:

CenterInParent(Me)

And this in a module:

Sub CenterInParent(ByRef frm As Object)
frm.Left = Higher((frm.Parent.ClientSize.Width - frm.Width) / 2, 0)
frm.Top = Higher((frm.Parent.ClientSize.Height - frm.Height) / 2,
0)
End Sub

Function Higher(ByRef x, ByRef y)
Higher = IIf(x y, x, y)
End Function

Feb 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
2
by: Henry Wu | last post by:
Hi,.. I have 2 forms with the same width & height, one with 100 opacity and the other with 50% opacity. Since I'm in an MDI application, the form with the 50% opacity cannot be a MDI Child or else...
3
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the...
1
by: Mitchell Vincent | last post by:
Strange thing is happening.. I have the StartPosition of my MDI child window set to CenterParent (at design time), yet when I close the window and re-open it the start position gets shifted down...
1
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
1
by: gplott | last post by:
I have an XML document that has multiple childe nodes like the one at the end of this message What syntax would I use with selectNodes to select all viewentry nodes that have an entrydata...
1
by: Brett Romero | last post by:
I set an MDI child form to Windowstate=maximized at design time. When I new up and show the child form in the MDI parent, the child's title is hidden since it's pushed to far up (below parent tool...
5
by: Earl | last post by:
I need to call a method on an owned child form, and am wondering if the best way of doing this is to capture the Closing event of the form that passes control back to the form where I have the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.