469,283 Members | 2,166 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

MDI Form loading

I am using the following to load my mdi form into the parent.

If Me.frmIncoming Is Nothing Then
Me.frmIncoming = New IncomingForm
Me.frmIncoming.MdiParent = Me
End If
Me.frmIncoming.Show()
Me.frmIncoming.Location = New Point(10, 450)

When the forms Show() method is called and before the location is
changed the form briefly appears at the default child MDI location
before moving. This looks terrible on screen as a user. Is there a
way of overriding the show method so it won't preposition the form? I
have tried placing the location before the Show() method but that
doesn't work.

Jun 29 '06 #1
5 5330
On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:
I am using the following to load my mdi form into the parent.

If Me.frmIncoming Is Nothing Then
Me.frmIncoming = New IncomingForm
Me.frmIncoming.MdiParent = Me
End If
Me.frmIncoming.Show()
Me.frmIncoming.Location = New Point(10, 450)

When the forms Show() method is called and before the location is
changed the form briefly appears at the default child MDI location
before moving. This looks terrible on screen as a user. Is there a
way of overriding the show method so it won't preposition the form? I
have tried placing the location before the Show() method but that
doesn't work.

You need to change the StartUpPosition from WindowsDefault to Manual.

I would avoid naming an instance of a form with same name as the
original form.

Dim ChildForm As New IncomingForm
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Location = New Drawing.Point(50, 50)
ChildForm.Show()
Jun 29 '06 #2
Thanks Gene, that gets me a little further. Now the form starts in the
correct position, however the border shows for a brief second before
disappearing. I do not want a border on the form. Basically what it
looks like to the user is a windows form flashes and then goes away.
Can I somehow get rid of this?
gene kelley wrote:
On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:
I am using the following to load my mdi form into the parent.

If Me.frmIncoming Is Nothing Then
Me.frmIncoming = New IncomingForm
Me.frmIncoming.MdiParent = Me
End If
Me.frmIncoming.Show()
Me.frmIncoming.Location = New Point(10, 450)

When the forms Show() method is called and before the location is
changed the form briefly appears at the default child MDI location
before moving. This looks terrible on screen as a user. Is there a
way of overriding the show method so it won't preposition the form? I
have tried placing the location before the Show() method but that
doesn't work.

You need to change the StartUpPosition from WindowsDefault to Manual.

I would avoid naming an instance of a form with same name as the
original form.

Dim ChildForm As New IncomingForm
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Location = New Drawing.Point(50, 50)
ChildForm.Show()


Jun 29 '06 #3
On 29 Jun 2006 15:36:22 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:
Thanks Gene, that gets me a little further. Now the form starts in the
correct position, however the border shows for a brief second before
disappearing. I do not want a border on the form. Basically what it
looks like to the user is a windows form flashes and then goes away.
Can I somehow get rid of this

Do you mean border of the child form at the default position flashes
before it actually displays in the correct position? Opening a new
MDI project here with a MDI Parent form, a form named IncomingForm,
and only the sample code I had in a click event, I do no see what you
describe. The child form displays as expected.

I have, however, run across that flashing business under other
circumstances. It usually has to do with some piece of code that is
executing and causing the form's visibility to change before the form
should be shown. One notorious example is trying to change the
WindowState to Maximized before the forms is shown. What you get is a
form border at Normal size and then a flash up to Maximized when the
form finishes loading.

1) Try stepping through the code starting at:
Dim ChildForm As New IncomingForm (or whatever you are using)
and see if you can detect where the ChildForm might be showing before
it should.

2) Try Starting a new MDI test project as I described and then adding
bits of code from your original IncomingForm and see if you can
determine where the flashing is occurring.

Gene
gene kelley wrote:
On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:
>I am using the following to load my mdi form into the parent.
>
> If Me.frmIncoming Is Nothing Then
> Me.frmIncoming = New IncomingForm
> Me.frmIncoming.MdiParent = Me
> End If
> Me.frmIncoming.Show()
> Me.frmIncoming.Location = New Point(10, 450)
>
>When the forms Show() method is called and before the location is
>changed the form briefly appears at the default child MDI location
>before moving. This looks terrible on screen as a user. Is there a
>way of overriding the show method so it won't preposition the form? I
>have tried placing the location before the Show() method but that
>doesn't work.

You need to change the StartUpPosition from WindowsDefault to Manual.

I would avoid naming an instance of a form with same name as the
original form.

Dim ChildForm As New IncomingForm
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Location = New Drawing.Point(50, 50)
ChildForm.Show()

Jun 30 '06 #4
I started a new project with 2 forms. Set form 1 to MDI parent and
added a button with the following code in the click event. Form2 is set
to no form border.

Dim ChildForm as New Form2
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Show()
ChildForm.Location = New Point(100, 100)

When you click the button it will create the second form, which for a
split second will appear with a border, then move to it's proper
location at 100,100.

gene kelley wrote:
On 29 Jun 2006 15:36:22 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:
Thanks Gene, that gets me a little further. Now the form starts in the
correct position, however the border shows for a brief second before
disappearing. I do not want a border on the form. Basically what it
looks like to the user is a windows form flashes and then goes away.
Can I somehow get rid of this

Do you mean border of the child form at the default position flashes
before it actually displays in the correct position? Opening a new
MDI project here with a MDI Parent form, a form named IncomingForm,
and only the sample code I had in a click event, I do no see what you
describe. The child form displays as expected.

I have, however, run across that flashing business under other
circumstances. It usually has to do with some piece of code that is
executing and causing the form's visibility to change before the form
should be shown. One notorious example is trying to change the
WindowState to Maximized before the forms is shown. What you get is a
form border at Normal size and then a flash up to Maximized when the
form finishes loading.

1) Try stepping through the code starting at:
Dim ChildForm As New IncomingForm (or whatever you are using)
and see if you can detect where the ChildForm might be showing before
it should.

2) Try Starting a new MDI test project as I described and then adding
bits of code from your original IncomingForm and see if you can
determine where the flashing is occurring.

Gene
gene kelley wrote:
On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:

>I am using the following to load my mdi form into the parent.
>
> If Me.frmIncoming Is Nothing Then
> Me.frmIncoming = New IncomingForm
> Me.frmIncoming.MdiParent = Me
> End If
> Me.frmIncoming.Show()
> Me.frmIncoming.Location = New Point(10, 450)
>
>When the forms Show() method is called and before the location is
>changed the form briefly appears at the default child MDI location
>before moving. This looks terrible on screen as a user. Is there a
>way of overriding the show method so it won't preposition the form? I
>have tried placing the location before the Show() method but that
>doesn't work.
You need to change the StartUpPosition from WindowsDefault to Manual.

I would avoid naming an instance of a form with same name as the
original form.

Dim ChildForm As New IncomingForm
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Location = New Drawing.Point(50, 50)
ChildForm.Show()


Jun 30 '06 #5
On 30 Jun 2006 08:59:34 -0700, "Charlie Brown" <cb****@duclaw.com>
wrote:
Dim ChildForm as New Form2
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Show()
ChildForm.Location = New Point(100, 100)

The above code will "flash" as you are moving the form after it is
shown. Try this:

Dim ChildForm As New Form2
ChildForm.MdiParent = Me
ChildForm.StartPosition = FormStartPosition.Manual
ChildForm.Location = New Point(100, 100)

ChildForm.Show()

Gene
Jun 30 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Chris Thunell | last post: by
3 posts views Thread by Eric | last post: by
reply views Thread by Joe | last post: by
2 posts views Thread by Geraldine Hobley | last post: by
4 posts views Thread by BerkshireGuy | last post: by
1 post views Thread by Mecena | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.