Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mousepointer does not get back from vbHourGlass to vbArrow 1

Status
Not open for further replies.

Erioly

Programmer
Sep 4, 2008
10
US
Hi folks! I am trying to fix an issue regarding a mousepointer that gets stuck as an hourglass even after the task is performed, without getting back to its arrow form. It is a pretty strange issue that many at my company have tried to solve but without succeeding at it...

The code goes something like this...

----------------form-----------------------

Screen.MousePointer = vbHourglass

'do lots of stuff

Screen.MousePointer = vbArrow
Set Timer = New Xtimer
Timer.Interval = 10
Timer.Enabled = True
Me.Show vbModal

-------------------timer-------------------

Private Sub Timer_Tick()
timer.enabled = false
Screen.mousepointer = vbArrow
end sub
--------------------------------------------

I have done everything to this code to get the arrow instead of the hourglass when the form shows up... but nothing seems to work. I have even tried this:

' commented this... Screen.MousePointer = vbHourglass

'do lots of stuff

' commented this as well Set Timer = New Xtimer
' Timer.Interval = 10
' Timer.Enabled = True

Screen.MousePointer = vbArrow
Me.Show vbModal



There also are two weird things about it:

1) If you debug it step by step, then you get the vbArrow mouse pointer, as it should. But if you run it without a breakpoint, it get the hourglass mouspointer

2) When you run it without a breakpoint, sometimes it will work with the sticked hourglass pointer and sometimes with the arrow mousepointer. It switches between these two scenarios at a completely randomized way


I would appreciate any idea about it. Someone said that, taking into consideration the two weird thing that i listed above, it should be a timming problem, but i did not understand what he meant.
 
the only way i was able to reproduce the behavior you describe is by setting enabled to false in the timers timer routine like this:

Private Sub Timer1_Timer()
Timer1.Enabled = False '<<<<<<<<<<<<<
Me.MousePointer = vbArrow
End Sub

and not setting it back to true BEFORE firing an event
so the behavior is a result of the code logic.

instead of using .enabled try using .interval only, for example:

Code:
Private Sub Command1_Click()
    Me.MousePointer = vbHourglass
    Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
    Timer1.Interval = 0
    Me.MousePointer = vbArrow
End Sub

if you are going to use enabled property you must reset the enabled property to true before >>>'do lots of stuff



 
oh and dont forget to set interval to zero in the timer event: Timer1.Interval = 0
 
It seems like a very good advice and I am so thankful for it. Nevertheless, I tried it and it is still behaving in the wrong way!! =(

Any other ideas??
 
Have you tried DoEvents directly after setting the pointer back to Arrow? I've run into similar problems like that and DoEvents seemed to clear a lot of it up.

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
that was a good one too, but didn't work =(
 
Try Me.MousePointer = vbDefault

[gray]Experience is something you don't get until just after you need it.[/gray]
 
...or better still: Screen.MousePointer = vbDefault

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Yeah, I've tried that already, but no results...
 
Question.

Are you sure the call is executing? If it is, is something else being executed immediately afterward that is reverting back to the HourGlass?

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
I have had this happen to me, usually when i am having the program do a lot of different things. Would run fine when you stepped through it, but wouldn't when i just let the program run. i solved it by moving the screem.mousepointer = 0 around until I found where it would always work, then look at the code right after that and try adding a DoEvents as was mentioned earlier. keep doing this until it runs correctly.
 
I am sure that the call is executing. I do have my mousepointer getting back to the hourglass after my //dostuff is called. BUT //dostuff happens to be a Me.show vbmodal, so the mousepointer is not suposed to be called after the user clicks exit in the displayed form and that is just way ahead of the problem... however, i have already tried commenting that line of code and still does not work. =(

yacyac, I will try what you say!!
 
Nope... I just pasted many many Screen.MousePointer = vbArrow in almost any line of my function and still does not do what is is suposed to... I'm almost thinking is some sort of strange vb6 issue...
 
>almost thinking is some sort of strange vb6 issue
Post the offending code so you can be sure.
 
Screen.MousePointer = vbArrow

Set m_oMouseTimer = New XTimer
With m_oMouseTimer
.Interval = 10
.Enabled = True
End With

Screen.MousePointer = vbArrow
Me.Show vbModal 'here is where i get the hourglass, sometimes...
Screen.MousePointer = vbArrow


----------------------

Private Sub m_oMouseTimer_Tick()
'm_oMouseTimer.Enabled = False jugomez
m_oMouseTimer.Interval = 0
'Screen.MousePointer = vbDefault jugomez
Screen.MousePointer = vbArrow
End Sub
 
Where do you call the HourGlass pointer at?

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
way behind! what i will do, just for giggles, is to inhibit the mouse pointer = hourglass and see what it happens.

but that will be on monday morning! have a nice weekend folks!! =)
 
the thing I am having trouble getting my head around is

WHY would you change your cursor for a Time Period

do You expect a routine to take X long
and so change cursor for x period of time

Would it not be better to

Change Cursor to Hourglass
Do the Routine
Change Cursor to Default at finish Of Routine

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top