Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing Mouse Pointer - Update

    Well I found the problem.

    Maybe I should be blushing with embarrassment.

    Seems if you want anything on a form to change if you enter a for loop, you better DoEvents inside the loop!

    Slows the action down by about 500 ms, but it's worth it.

    Now for a real humdinger. If what I wanted in the first place was a way to tell the user to Please wait..., why not create a graphic of a little window with the words "Please wait..." and replace the mouseicon with that graphic?

    Can you replace a mouseicon with an animated .gif? Of course! So, the Please wait doesn't have to just sit there. I gotta try this. If you do before me, post back post haste!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Changing Mouse Pointer - Update

    I'm happy to know the answer. It does make sense that the mouse pointer is a feature of Windows, even if the syntax hides that fact.

    In Lomax, he says a million count loop will take 49.5 seconds longer to iterate if you call DoEvents every time. This is only a long time compared with the 0.3 seconds it takes without DoEvents. But... you don't need to call it inside the loop. This works just fine (assuming a form with an appropriate button):

    Private Sub CommandButton1_Click()
    Call TogglePointer
    DoEvents
    For i = 1 To 3000
    Me.Repaint
    Me.Label1 = Str(i)
    Next
    Call TogglePointer
    End Sub

    Private Sub TogglePointer()
    If UserForm1.MousePointer <> fmMousePointerHourGlass Then
    UserForm1.MousePointer = fmMousePointerHourGlass
    Else
    UserForm1.MousePointer = fmMousePointerDefault
    End If
    End Sub

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Mouse Pointer - Update

    Jeff,

    Right you are! I moved DoEvents outside the loop and it works fine (I thought I tried this once and it did not work, so I tried it again based on your post). It saves some time too. Thanks.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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