?
Solved

Mousepointer when positioned off of a form

Posted on 2003-02-25
8
Medium Priority
?
274 Views
Last Modified: 2010-04-07
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
Comment
Question by:isrspgmr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8019551
Could you set vbhourglass pointer in click event of the button too?
0
 

Author Comment

by:isrspgmr
ID: 8019705
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
 
LVL 3

Accepted Solution

by:
Da_Weasel earned 200 total points
ID: 8019872
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!

 

Expert Comment

by:RMatzka
ID: 8019875
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
 
LVL 3

Expert Comment

by:Egore
ID: 8020329
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
 

Author Comment

by:isrspgmr
ID: 8020490
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
 

Author Comment

by:isrspgmr
ID: 8020501
Thanks for the help.  I'll have to look into the DoEvents further.
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8020560
DoEvents basicly stops execution of your code and allows your program to process any waiting messages and then continues again.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question