Smooth transition between forms - ShowDialog and hide parent

D

dbuchanan

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(ByVal......
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
 
N

Nick

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

Chris

dbuchanan said:
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(ByVal......
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

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.Parent, MainFormType).Visble = 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
 

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