• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Mousepointer when positioned off of a form

I have a VB6 application performing a function that takes several seconds, triggered by a command button.  The form only takes up about a quarter of the screen. I change the mousepointer to vbhourglass in that initial form, while it is executing code to gather and display data on a separate form.

This works fine, if the button is clicked, or if you tab to the button, and use the enter key, as long as the mouse is positioned over the form at the time. If you use the tab/enter, while the pointer is outside the form, on a different application or the desktop, the pointer stays at vbdefault, even if you move the pointer back to the form while to code is still executing.  

Is there a way around this, to get the pointer to change to hourglass when postioned over the form ?
0
isrspgmr
Asked:
isrspgmr
1 Solution
 
Richie_SimonettiIT OperationsCommented:
Could you set vbhourglass pointer in click event of the button too?
0
 
isrspgmrAuthor Commented:
Sorry, should have been clearer.  The click event of the button is exactly where the code is.  It changes to vbhourglass on the click, which executes the second form.  I change the pointer back to vbdefault, still within that same button click event, when the second form (modal) is closed, returning control to the main form.

While the second form is open, it's mousepointer is vbdefault, but it takes several seconds for that form to display.

The click event of the button is also executed by setting focus (tabbing to the button) and using the enter key.  It is when I do this, without the mousepointer being over the main form that this problem occurs.
0
 
Da_WeaselCommented:
I made 2 buttons one sets the Screen.MousePointer = vbHourGlass and the other Screen.MousePointer = vbNormal
It seems to work fine here, I move my mouse outside of the form and TAB/ENTER the vbHourGlass button and when I move my mouse pointer back to the from it shows the hourglass.

The only thing I can think of is that your loop has started and the form cant repond to any other messages.  You might consider putting a DoEvents statement in your loop.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RMatzkaCommented:
I think all you need to do is insert a few "DoEvents" statements into the code that performs the "several seconds" task, to give the system a chance to update the mouse pointer when it is over Form1.
0
 
EgoreCommented:
I've seen this happen to me when I set the mouse to an hourglass while the form is hidden and then show the form.  However, this only happens to me when running the application from Visual Basic, have you tried compiling it and running the EXE?
0
 
isrspgmrAuthor Commented:
DoEvents worked. Thanks to both of you who answered this, apparently at the same time.  I'm going to accept the answer from Da Weasel, then I will post another Question, with a subject of "Points for RMatza" to give you points also.  
0
 
isrspgmrAuthor Commented:
Thanks for the help.  I'll have to look into the DoEvents further.
0
 
Da_WeaselCommented:
DoEvents basicly stops execution of your code and allows your program to process any waiting messages and then continues again.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now