MDI Form loading

C

Charlie Brown

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.
 
G

gene kelley

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()
 
C

Charlie Brown

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?
 
G

gene kelley

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
 
C

Charlie Brown

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.
 
G

gene kelley

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
 

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