Results 1 to 6 of 6

Thread: [RESOLVED] Help needed! DoEvents doesnt works

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [RESOLVED] Help needed! DoEvents doesnt works

    Hi.
    My app executes a function that takes a lot of time.
    Therefor, I created a form with a little animation made with 12 icons placed in a imagelist.
    Right before the execution of that function, I load that form.
    The form has a timer, so each 1/2 second it changes the image in the form icon and the image of image" object.

    Code:
    Private Sub Timer1_Timer()
    Me.SetFocus
    DoEvents
    
    Me.Refresh
    Me.Image1.Refresh
    i = i + 1
    Me.Image1 = Me.ImageList1.ListImages(i).Picture
    Me.Icon = Me.ImageList1.ListImages(i).Picture
    
    If i = 12 Then i = 1
    
    
    End Sub
    What happens is that I cant see the animation "running".
    In the mainForm I have this code:

    Code:
    '...
    FormWait.Show
    FormWait.SetFocus
    DoEvents
    verify = Generate.PS2(file)
    Unload FormWait
    '...
    Thanks
    Last edited by RS_Arm; May 21st, 2007 at 04:50 AM.

  2. #2
    Addicted Member
    Join Date
    Mar 2006
    Posts
    178

    Re: Help needed! DoEvents doesnt works

    How is 'i' defined? If it's not defined at all 'i' will never get to a value higher than 1.
    If a post has been helpful, Rate it!

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Help needed! DoEvents doesnt works

    Also...If your code runs a loop, place the doevent inside that loop (inside Generate.PS2 method).

    vb Code:
    1. Private Function YourCPUIntensiveFunction() As Long
    2.    
    3.     Do While (SomeCondition)
    4.          DoEvents
    5.          ' Do The Job
    6.     Loop      
    7. End Function
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Help needed! DoEvents doesnt works

    Well, i is defined as integer.
    If I run the ForWait as StandAlone, the animation works well.

    To iPrank
    My function is called by a dll.
    Should I put DoEvents in the dll?

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Help needed! DoEvents doesnt works

    I'm not sure about how DoEvents works on threads (or how the dll uses threading)...but if you have the source code give it a try.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Help needed! DoEvents doesnt works

    Ok, I've tryed to put DoEvents on the dll function and it worked.
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width