[RESOLVED] how to make a "Please Wait While.." form
VB6 app.
Connecting remotely to my database can take sometime... I would like to have a form load that disables the original form show onscreen and reads simply, "Please wait while I process your request."
Then when the connection is made, the info is queried and filled, have the please wait form unload itself.
I tried wrapping my connections with:
Code:
frmWait vdModal, Me
all my code and fillfields stuff here
unload frmwait
but that didn't work. frmWait never unloads... I guess because it is shown modally. However, I thought that was a decent idea. Maybe that idea just needs from tweaking?
Re: how to make a "Please Wait While.." form
I don't think you want to show your wait form as vbModal. All processing would be stopped on the calling form.
I had a similar need a couple of years ago and I ended up using a Hidden Picture Box that had the topmost ZOrder when displayed. When done processing just hide the Picture Box. You could also include a progress bar if that is appropriate for what your doing.
Re: how to make a "Please Wait While.." form
Oh, I didn't realize modal stopped processing on that form. Thanks.
I will try something like your picturebox idea.
Re: how to make a "Please Wait While.." form
Why not just change to a form with no clipbox, however make sure you put a button on it like disconnect or cancel if your not using a timer to abort the connection process after a given time.
Assuming you are using Winsock, just make a callback function to return the socket.state in actual words and pass it to your label so the user knows whats going on during the establishment of the connection.
Re: how to make a "Please Wait While.." form
Do you want to do something like this?
Code:
Option Explicit
Private Sub Form_Load()
Label1.Caption = ""
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim MyWord
Static i As Integer
i = i + 1
MyWord = Array("L", "o", "a", "d", "i", "n", "g", ".", ".", ".", ".", ".")
Label1.Caption = Label1.Caption & MyWord((i) - 1)
If i = 12 Then
i = 0
Label1.Caption = ""
End If
End Sub
Re: how to make a "Please Wait While.." form
Just do this:
Code:
frmWait.Show , Me
Me.Enabled = False
all my code and fillfields stuff here
unload frmWait
Me.Enabled = True
Re: how to make a "Please Wait While.." form
Be careful if you choose to use a non-modal form for the display. It can easily get lost behind other forms which is the very reason I went with the Picture Box. That can happen even if you use the OnTop API.
Re: how to make a "Please Wait While.." form
Thank you for the posts and suggestions.
I was also trying to do CVMichael's idea recently, but it was getting lost behind forms at times.
That was why I tried showing it modally.
Re: how to make a "Please Wait While.." form
When you set the OwnerForm, it's impossible that it goes behind the owner window...
Are you sure you set the OwnerForm ?
frmWait.Show , Me
Re: how to make a "Please Wait While.." form
To extend on that...
You basically have 3 states:
This is non-modal, and it can go behind other forms
frmWait.Show
This is non-modal, but it does NOT go behind it's Owner
frmWait.Show , Me
This is Modal, and and it also stops execution of code in the Owner until it's closed
frmWait.Show vbModal, Me
For example, start a new project, add 2 more forms, try this code
Code:
Private Sub Form_Load()
Form1.Show
Form2.Show , Form1
Form3.Show , Form2
End Sub
And also try this
Code:
Private Sub Form_Load()
Form1.Show
Form2.Show , Form1
Form3.Show , Form1
End Sub
Notice the difference in the Owner in both examples
Re: how to make a "Please Wait While.." form
Nope, I didn't set the owner form... I am using it now, seems to work for me.
Also tossing around the picturebox idea... I fill it with a picture that says "Please Wait" while disabling me.form. Then enabling the form after everything is processed.
Thanks for your help.
I also like using CDRIVE's LOADING form. Good stuff.
Re: how to make a "Please Wait While.." form
Ok, this is resolved. Most of the reason why I wanted this to work was because of my remote db connection. I have used adAsynConnect when my connections are open, and I use a "Loading" animation (with help from si the geek) on a separate thread.
I disabled the form while it's connecting, upon connection_complete event, I re-enable the form. The user stays on the form the whole time, and can visually see the "Loading" animation in the top right corner, so he/she knows my application is connecting properly.
Thanks.