467,880 Members | 1,128 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,880 developers. It's quick & easy.

Play animated gif on waiting

Hi..
I am developing an application that connect to database on the other
side of the net.
And each time i want to connect to database and run some sql command,
i want my user to know that there is some process is runing. My idea
is to show animated gif until the process is done.
My question is how i could achieved that? Any one could give me a clue
or hint or even sample code?
Thank you?
This is my snippet code:

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click
Dim strQuery As String
Dim Connection As New clsConnection 'I am using my class
Dim Settings As New clsSettings 'I am using my class
Dim blnConnect As Boolean = False
Private Const strAppName As String
If NotNull(txtName) Or NotNull(txtUnit) Or NotNull(txtPacking)
Or NotNull(txtPoint) Or NotNull(txtPricePoint) Or NotNull(txtPrice)
Then
MsgBox("Data with * mark must not empty.",
MsgBoxStyle.Information, "Information")
Exit Sub
End If
'Here i want o star play animated gif
If
Connection.OpenConnection(Settings.getStrConnectio n(strAppName)) =
True Then
Clear()
blnConnect = True
Else
'stop animated gif
MsgBox("Could not connect to database.",
MsgBoxStyle.Critical, "Warning.")
blnConnect = False
Exit Sub
End If
strQuery = "Insert Into products
(name,unit,packaging,point,price_point,price) VALUES ('" &
txtName.Text & "','" & _
txtUnit.Text & "','" & txtPacking.Text & "','" &
txtPoint.Text & "','" & txtPricePoint.Text & "','" & _
txtPrice.Text & "')"

Select Case conProduct.Transaction(strQuery)
Case Is < 0
MsgBox("There is an error when saving data.",
MsgBoxStyle.Information, "Information")
Connection.TerminateDatabase()
'stop animated gif
Exit Sub
Case Is = 0
MsgBox("There is no data saved.",
MsgBoxStyle.Information, "Information")
Connection.TerminateDatabase()
'stop animated gif
Exit Sub
Case Else
MsgBox("Data has been saved.",
MsgBoxStyle.Information, "Information")
End Select
Connection.TerminateDatabase()
'stop animated gif
Clear()
End Sub

Jun 23 '07 #1
  • viewed: 13910
Share:
7 Replies
Alfred

Drag a picturebox on your form
Set it to dock fill
Set Sizemode to StretchImaga
Choose in your property box your gif annimation

That is all

Cor
"Lemune" <al**************@gmail.comschreef in bericht
news:11*********************@z28g2000prd.googlegro ups.com...
Hi..
I am developing an application that connect to database on the other
side of the net.
And each time i want to connect to database and run some sql command,
i want my user to know that there is some process is runing. My idea
is to show animated gif until the process is done.
My question is how i could achieved that? Any one could give me a clue
or hint or even sample code?
Thank you?
This is my snippet code:

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click
Dim strQuery As String
Dim Connection As New clsConnection 'I am using my class
Dim Settings As New clsSettings 'I am using my class
Dim blnConnect As Boolean = False
Private Const strAppName As String
If NotNull(txtName) Or NotNull(txtUnit) Or NotNull(txtPacking)
Or NotNull(txtPoint) Or NotNull(txtPricePoint) Or NotNull(txtPrice)
Then
MsgBox("Data with * mark must not empty.",
MsgBoxStyle.Information, "Information")
Exit Sub
End If
'Here i want o star play animated gif
If
Connection.OpenConnection(Settings.getStrConnectio n(strAppName)) =
True Then
Clear()
blnConnect = True
Else
'stop animated gif
MsgBox("Could not connect to database.",
MsgBoxStyle.Critical, "Warning.")
blnConnect = False
Exit Sub
End If
strQuery = "Insert Into products
(name,unit,packaging,point,price_point,price) VALUES ('" &
txtName.Text & "','" & _
txtUnit.Text & "','" & txtPacking.Text & "','" &
txtPoint.Text & "','" & txtPricePoint.Text & "','" & _
txtPrice.Text & "')"

Select Case conProduct.Transaction(strQuery)
Case Is < 0
MsgBox("There is an error when saving data.",
MsgBoxStyle.Information, "Information")
Connection.TerminateDatabase()
'stop animated gif
Exit Sub
Case Is = 0
MsgBox("There is no data saved.",
MsgBoxStyle.Information, "Information")
Connection.TerminateDatabase()
'stop animated gif
Exit Sub
Case Else
MsgBox("Data has been saved.",
MsgBoxStyle.Information, "Information")
End Select
Connection.TerminateDatabase()
'stop animated gif
Clear()
End Sub

Jun 23 '07 #2
"Cor Ligthert [MVP]" <no************@planet.nlschrieb
Alfred

Drag a picturebox on your form
Set it to dock fill
Set Sizemode to StretchImaga
Choose in your property box your gif annimation

That is all

Will it be animated in another thread? (I didn't try) Because the same
thread will be blocked.
Armin

Jun 23 '07 #3
I have tried your suggestion Cor.
And I'm using Property Visible
But for my application it doesn't work.
So i tried make a simple one that use command button and it's work
well.
This is my simple application:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
if pbAnimation.Visible=True Then
pbAnimation.Visible=False
else
pbAnimation.Visible=True
end if
End Sub

But for real application (my question), it not work, it didn't showing
the animation.

Jun 25 '07 #4
Lemune,

At least you have to put it on a seperate form.
I thougth that was working because the gif has its own annimation however I
am not sure of that.

Cor

"Lemune" <al**************@gmail.comschreef in bericht
news:11**********************@d30g2000prg.googlegr oups.com...
>I have tried your suggestion Cor.
And I'm using Property Visible
But for my application it doesn't work.
So i tried make a simple one that use command button and it's work
well.
This is my simple application:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
if pbAnimation.Visible=True Then
pbAnimation.Visible=False
else
pbAnimation.Visible=True
end if
End Sub

But for real application (my question), it not work, it didn't showing
the animation.

Jun 25 '07 #5
Thanks Cor, for your answer.
But it still not working.
I create a simple form that only had pbAnimation.
Then in my application(the question), first i create the instance of
the form, then show it.
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click
Dim frmPending As New Pending
frmPending.Show()
'
'
'
On each time i want to stop the animation, I hide the form. But It's
doesn't work like i wanted.
It still didn't show the animated gif, the time to load is about 3 s.

Jun 26 '07 #6
"Lemune" <al**************@gmail.comschrieb
Thanks Cor, for your answer.
But it still not working.
I create a simple form that only had pbAnimation.
Then in my application(the question), first i create the instance of
the form, then show it.
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click
Dim frmPending As New Pending
frmPending.Show()
'
'
'
On each time i want to stop the animation, I hide the form. But It's
doesn't work like i wanted.
It still didn't show the animated gif, the time to load is about 3
s.

As I guessed, the animation does not show because there is no time to
animate the gif because the thread is busy opening the connection. So you
have (at least) two options: Create a Form containing the Gif, as Cor said,
but in another thread. The thread won't be blocked and can animate the Gif.
Or, keep the gif on the same Form and open the connection in another thread.
This will take some more efforts because the application will have to handle
a "opening connection" state and your sub will have to be split into two
parts: one before and one after opening the connection. If it's worth just
for an animated Gif, I would probably put the whole saving task into a
seperate thread, not only opening the connection (unless you need it
multiple times; as always it depends...). Otherwise just show the
"WaitCursor" Cursor.
Armin

Jun 26 '07 #7
Thanks Cor and Armin.
I will use wait cursor instead.
My purpose is to make user know that something is in process, and with
wait cursor i think is enough, because microsoft also used it.
So my user will be knew about it
Once again thanks for both of you.

Lemune,
Always learn.

Jun 26 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Sparks | last post: by
9 posts views Thread by John J. Hughes II | last post: by
7 posts views Thread by Gary Kaucher | last post: by
2 posts views Thread by Ben Fidge | last post: by
27 posts views Thread by Phil | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.