Smooth transition between forms - ShowDialog and hide parent

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

    #1

    Smooth transition between forms - ShowDialog and hide parent

    Hello,

    My application has a series of forms that open using ShowDialog() on
    top of their parent as the user drills down to enter increasingly more
    detail regarding data. I want to hide the previous form so that the
    user can minimize or move the current form without others behind it.

    Currently I am using this code;

    \\
    Private Sub btnJobForm(ByVa l......
    Dim f As New f010Jobs
    Me.Visible = False
    f.ShowDialog()
    Me.Visible = True
    End Sub
    //

    However there is a cosmetic drawback to this. The first form disappears
    before the new form fully paints. The affect is unprofessional.

    On return everything looks fine.

    I don't know how to make the form disappear later unless the new form
    tells its parent to disappear, but I don't know how to do that either.

    What are my options? What is the best way to resolve this problem?

    Thank you,
    dbuchanan

  • Nick

    #2
    Re: Smooth transition between forms - ShowDialog and hide parent

    Hi there,

    One thing you could do is pass the previous form as an object to the
    next form on initialization. Then when the "Activate" event fires in the
    next form, this is your time to call the "Hide" method of the previous form.

    1. Initialize form (next) passing current form to constructor
    2. Call ShowDialog of (next)
    3. In Active event of (next) form call Hide on form passed during
    construction, making sure you raise a static boolean within the active event
    handler to prevent hiding every time the form is activated as you only want
    this to happen once.

    Just an idea anyway, not actually tried it, but in theory it should
    work.

    Nick.

    "dbuchanan" <dbuchanan52@ho tmail.com> wrote in message
    news:1128434360 .669481.325470@ g14g2000cwa.goo glegroups.com.. .[color=blue]
    > Hello,
    >
    > My application has a series of forms that open using ShowDialog() on
    > top of their parent as the user drills down to enter increasingly more
    > detail regarding data. I want to hide the previous form so that the
    > user can minimize or move the current form without others behind it.
    >
    > Currently I am using this code;
    >
    > \\
    > Private Sub btnJobForm(ByVa l......
    > Dim f As New f010Jobs
    > Me.Visible = False
    > f.ShowDialog()
    > Me.Visible = True
    > End Sub
    > //
    >
    > However there is a cosmetic drawback to this. The first form disappears
    > before the new form fully paints. The affect is unprofessional.
    >
    > On return everything looks fine.
    >
    > I don't know how to make the form disappear later unless the new form
    > tells its parent to disappear, but I don't know how to do that either.
    >
    > What are my options? What is the best way to resolve this problem?
    >
    > Thank you,
    > dbuchanan
    >[/color]


    Comment

    • Chris

      #3
      Re: Smooth transition between forms - ShowDialog and hide parent

      dbuchanan wrote:[color=blue]
      > Hello,
      >
      > My application has a series of forms that open using ShowDialog() on
      > top of their parent as the user drills down to enter increasingly more
      > detail regarding data. I want to hide the previous form so that the
      > user can minimize or move the current form without others behind it.
      >
      > Currently I am using this code;
      >
      > \\
      > Private Sub btnJobForm(ByVa l......
      > Dim f As New f010Jobs
      > Me.Visible = False
      > f.ShowDialog()
      > Me.Visible = True
      > End Sub
      > //
      >
      > However there is a cosmetic drawback to this. The first form disappears
      > before the new form fully paints. The affect is unprofessional.
      >
      > On return everything looks fine.
      >
      > I don't know how to make the form disappear later unless the new form
      > tells its parent to disappear, but I don't know how to do that either.
      >
      > What are my options? What is the best way to resolve this problem?
      >
      > Thank you,
      > dbuchanan
      >[/color]

      Haven't done this, but should work...

      In you subforms do something like:
      sub Form_Load Event
      addhandler Me.Activated, addressof ActivatedSub
      end Sub

      sub ActivatedSub
      directcast(Me.P arent, MainFormType).V isble = false
      removehandler me.activated, addressof ActivatedSub
      end sub

      Activated only fires once the form is ready to display. I remove the
      handler to stop it from repeatedly calling the code every time you
      alt-tab back to the form. Not sure if parent gets set automatically
      when you call showdialog, you may need to set it before calling showdialog.

      Chris

      Comment

      Working...