MDI Child start position

G

Guest

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
 
T

teslar91

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
 
G

Guest

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
 
G

Guest

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
 

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