Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I want to show an animated gif if some execution is done instead of setting the cursor to "WaitCursor". At the time I would set my cursor I openl a form which contains an animated gif. But the gif is only animated after my execution finished. What's wrong?
Posted

You would need to play the gif just before the execution begins...

 

Using the mouse events would be most helpful...

 

in VB, the mouse events are executed in sequence:

Mouse_Down()

Mouse_Up()

Click()

DoubleClick()

 

This will work best if you put it in the _MouseUp event...

 

Take a button for instance...

NOTE: In this example, I would put my code that I want to execute in the button1_click() event...

Private Sub button1_MouseUp(blah)
 'Play Gif Code Here...
End Sub

Private Sub button1_Click(blah)
 'Put Work Code Here...
End Sub

 

Now when the user presses down AND THEN releases the mouse on button1, the gif will start playing while the code executes...

UCM

>-)

Posted

Unfortunately it makes no difference....

 

This is how I do it, maybe you can see an error.

 

If Not objWordInstance Is Nothing Then
   frmGif = New frmIBS_Beschaeftigt() 
   frmGif.AnimateImage()
  [...]
  .FillDocVariables(...)
   frmGif.Close()
   frmGif = Nothing
End If

 

where frmGif is my form with the animated gif and .FillDocVariables is the sub whose execution should be shown by that gif.

Posted (edited)

ok, your code snippit is the code used to open the gif...

 

What is the general idea of what your application does when it goes into a long process where you would need the waiting gif?

 

What event is this code in?

 

It looks like you are going to fill a table with data...

 

The gif doesn't play until after the data is filed? or is it something else?

Edited by UCM

UCM

>-)

Posted

The code snippit is only one example. I want to use my animated gif at several places.

 

I am developing an AddIn for Word(2000).

 

The snippit I copied here is used to parse to one document to search for DocVariables in it. To each of this DocVariable I have an entry in my CustomDocumentProperties containing a SQL-statement. I must execute that SQL-statement and the value I get becomes the value of the DocVariable.

 

Yes, when all my DocVariables are filled (which means the execution of that function is finished), my gif starts to play. But I want it to be parallel. I think the only way may be to do that by using several threads???

  • *Gurus*
Posted
You are probably right. If the function is executing lots of things in a loop, you might be able to get away with sticking an Application.DoEvents() in the loop. Otherwise, you'll probably have to execute that function in a new thread.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Even if using threads it seems to be more difficult than I thought.

 

It seems to work... My function fills my DocVariables and during that I see my animated gif and it is(!) animated. But: how can I tell that form when to close?

 

Maybe you can have one look at my code and give me a hint?!

 

I created a new class:

Public Class IBSThread
   Public objQueryParameters As ArrayList
   Public Doc As Word.Document
   Public mobjProperties As DocProperties
   Public blnPushed As Boolean
   Public IBSWord As New comIBS_Word()
   Public Event Done()

   Public Sub Sub1()
       IBSWord.FillDocVariables(Doc, mobjProperties, objQueryParameters, Not blnPushed)
       RaiseEvent Done()
   End Sub
End Class

 

And this is the "main" program (frmGif is declared modally)

With objConnect.objIBS_Word
   .ResetDocVariables(...)
   .ParameterZufuegen = False 
   .DokumentVariablen = mobjProperties
   If Not objWordInstance Is Nothing Then
       Dim myThread As Threading.Thread
       .IstVorschau = True
       objQueryParameters = New ArrayList()
       objQueryParameters.Clear()
       objQueryParameters.Add(objIBS_INIT.ibsKrankenhausNr)
       objQueryParameters.Add(objIBS_INIT.ibsAbteilung)
       objQueryParameters.Add(objIBS_INIT.ibsVorlage)

       clsThread = New IBSThread()
       clsThread.blnPushed = Me.tlbButtonVorNach.Pushed
       clsThread.Doc = CType(objWordInstance.ActiveDocument, Word.Document)
       clsThread.mobjProperties = mobjProperties
       clsThread.objQueryParameters = objQueryParameters
       clsThread.IBSWord = objConnect.objIBS_Word

       myThread = New Threading.Thread(AddressOf clsThread.Sub1)
       myThread.Name = "IBS Thread"
       myThread.Start()

       frmGif = New frmIBS_Beschaeftigt() 
       frmGif.ShowDialog()
   End if
End with

 

Here's the handling of the event

Private Sub clsThread_Done() Handles clsThread.Done
   frmGif.Close()
      
   ChangeSize(False)
End Sub

 

But my form is not being closed! Why?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...