MDI Form loading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charlie Brown

    #1

    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.

  • gene kelley

    #2
    Re: MDI Form loading

    On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cbrown@duclaw. com>
    wrote:
    [color=blue]
    >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.[/color]
    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.MdiPa rent = Me
    ChildForm.Start Position = FormStartPositi on.Manual
    ChildForm.Locat ion = New Drawing.Point(5 0, 50)
    ChildForm.Show( )


    Comment

    • Charlie Brown

      #3
      Re: MDI Form loading

      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:[color=blue]
      > On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cbrown@duclaw. com>
      > wrote:
      >[color=green]
      > >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.[/color]
      > 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.MdiPa rent = Me
      > ChildForm.Start Position = FormStartPositi on.Manual
      > ChildForm.Locat ion = New Drawing.Point(5 0, 50)
      > ChildForm.Show( )[/color]

      Comment

      • gene kelley

        #4
        Re: MDI Form loading

        On 29 Jun 2006 15:36:22 -0700, "Charlie Brown" <cbrown@duclaw. com>
        wrote:
        [color=blue]
        >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[/color]


        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


        [color=blue]
        >gene kelley wrote:[color=green]
        >> On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cbrown@duclaw. com>
        >> wrote:
        >>[color=darkred]
        >> >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.[/color]
        >> 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.MdiPa rent = Me
        >> ChildForm.Start Position = FormStartPositi on.Manual
        >> ChildForm.Locat ion = New Drawing.Point(5 0, 50)
        >> ChildForm.Show( )[/color][/color]

        Comment

        • Charlie Brown

          #5
          Re: MDI Form loading

          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.MdiPa rent = Me
          ChildForm.Start Position = FormStartPositi on.Manual
          ChildForm.Show( )
          ChildForm.Locat ion = 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:[color=blue]
          > On 29 Jun 2006 15:36:22 -0700, "Charlie Brown" <cbrown@duclaw. com>
          > wrote:
          >[color=green]
          > >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[/color]
          >
          >
          > 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
          >
          >
          >[color=green]
          > >gene kelley wrote:[color=darkred]
          > >> On 29 Jun 2006 13:05:49 -0700, "Charlie Brown" <cbrown@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.MdiPa rent = Me
          > >> ChildForm.Start Position = FormStartPositi on.Manual
          > >> ChildForm.Locat ion = New Drawing.Point(5 0, 50)
          > >> ChildForm.Show( )[/color][/color][/color]

          Comment

          • gene kelley

            #6
            Re: MDI Form loading

            On 30 Jun 2006 08:59:34 -0700, "Charlie Brown" <cbrown@duclaw. com>
            wrote:
            [color=blue]
            >Dim ChildForm as New Form2
            >ChildForm.MdiP arent = Me
            >ChildForm.Star tPosition = FormStartPositi on.Manual
            >ChildForm.Show ()
            >ChildForm.Loca tion = New Point(100, 100)[/color]


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

            Dim ChildForm As New Form2
            ChildForm.MdiPa rent = Me
            ChildForm.Start Position = FormStartPositi on.Manual
            ChildForm.Locat ion = New Point(100, 100)

            ChildForm.Show( )

            Gene

            Comment

            Working...