Select to view content in your preferred language

IMouseCursor does not stay set to hourglass whle query runs

2012
5
08-12-2010 04:41 AM
CarlosPiccirillo
Emerging Contributor
Hi everyone,

I have a form which has a listbox on it displaying all lakes in the state so the user can select which one they want to load and zoom to.

On the InitializeComponent(); section of a C# form, I set the mouse cursor to an hourglass with this code:

IMouseCursor pMouseCursor = new MouseCursorClass();
pMouseCursor.SetCursor(2);


Right after this line, the code calls another method which queries the lakes layer, puts all of the names into an array and returns this to the listbox for display. As soon as the code goes to the method that does the query, the cursor returns to the pointer instead of staying an hourglass. Trying to set the cursor back to hourglass inside of this query method has no effect.

This query can sometimes take up to a minute to run depending on network traffic so I definitely want to show the user that code is running and not have them think the program is locked up.

Any ideas on how to fix this?

Thanks,
Carlos
0 Kudos
5 Replies
JamesCrandall
MVP Alum
Carlos,

Have you tried to implement the cursor from the parent Windows form?

Prior to the method call, set the cursor (VB.NET):

Windows.Forms.Cursor.Current = Cursors.WaitCursor



After the method and the return to the form, re-set the cursor:


Windows.Forms.Cursor.Current = Cursors.Arrow




Hope this helps,

james
0 Kudos
CarlosPiccirillo
Emerging Contributor
Thanks for the reply James and my apologies for replying so late. The new forums is not notifying me of when I get a new message in spite of me setting it to send email immediately so if I forget to check for new messages myself, I don't see them and in this case, I got pulled away from this problem to take care of another one. 😞

Anyhow, I will give your suggestion a try.

Carlos

Carlos,

Have you tried to implement the cursor from the parent Windows form?

Prior to the method call, set the cursor (VB.NET):

Windows.Forms.Cursor.Current = Cursors.WaitCursor



After the method and the return to the form, re-set the cursor:


Windows.Forms.Cursor.Current = Cursors.Arrow




Hope this helps,

james
0 Kudos
JamesCrandall
MVP Alum
No problem at all.  Any new major switch is going to cause disruptions, and I think this forum has a ways to go to get at the activity levels seen in previous versions --- it's just a part of making major changes like this I guess. 

Please post up your solution when you find it!  I know what I have posted does work for many of the apps I have implemented and currently maintain (all are VB.NET framwork 3.5/ ArcGIS 9.3.1), so I'd like to hear if you found another way to accomplish this.

{Also: are you in the West Palm Beach office off of Gun Club Rd?  I'm originally from Lantana (Palm Beach County) and return quite often to visit family and freinds --- I've been residing in Charlotte County since 1999}

Take Care,

james

Thanks for the reply James and my apologies for replying so late. The new forums is not notifying me of when I get a new message in spite of me setting it to send email immediately so if I forget to check for new messages myself, I don't see them and in this case, I got pulled away from this problem to take care of another one. 😞

Anyhow, I will give your suggestion a try.

Carlos
0 Kudos
CarlosPiccirillo
Emerging Contributor
James,

I was not able to get it to work with your suggestions but by pure trial and error, I was able to solve it. At one point, the code that populates the listbox, uses ITrackCancel to sort the results before displaying them in the listbox and when it hits that line of code, the cursor goes back to a pointer. Reissung pMouseCursor.SetCursor(2); right afterwards resets the cursor back to the hourglass for the duration of the code. The cursor does briefly (a second or two) switches to the pointer between the two lines of code but that's fine.

Yes, I am in the West Palm office off Gun Club road. Did you work at the District in the past? Your name does sound familiar to me for some reason. I've been here since 1988.

Anyhow, thanks for your time and your help. As always, I appreciate it a lot!!!
Carlos



No problem at all.  Any new major switch is going to cause disruptions, and I think this forum has a ways to go to get at the activity levels seen in previous versions --- it's just a part of making major changes like this I guess. 

Please post up your solution when you find it!  I know what I have posted does work for many of the apps I have implemented and currently maintain (all are VB.NET framwork 3.5/ ArcGIS 9.3.1), so I'd like to hear if you found another way to accomplish this.

{Also: are you in the West Palm Beach office off of Gun Club Rd?  I'm originally from Lantana (Palm Beach County) and return quite often to visit family and freinds --- I've been residing in Charlotte County since 1999}

Take Care,

james
0 Kudos
JamesCrandall
MVP Alum
Carlos,

Glad to hear you figured it out.  I'm unsure where exactly you'd need to put the Windows.Forms.Cursor.Current property in your app to get it to work --- I have placed these at the beginning and end of a click events in several of my apps (Windows form control) and have no problems.

No, never did work at SFWD but a while ago Chickasaw Nation I think was the GIS contractor for the Everglades restoration project and they approached me to see about a temporary developer position located in that office --- nothing ever came out of it, I think because they lost the contract?  Not sure.  Perhaps you were there at the interview.

Good luck.

james




James,

I was not able to get it to work with your suggestions but by pure trial and error, I was able to solve it. At one point, the code that populates the listbox, uses ITrackCancel to sort the results before displaying them in the listbox and when it hits that line of code, the cursor goes back to a pointer. Reissung pMouseCursor.SetCursor(2); right afterwards resets the cursor back to the hourglass for the duration of the code. The cursor does briefly (a second or two) switches to the pointer between the two lines of code but that's fine.

Yes, I am in the West Palm office off Gun Club road. Did you work at the District in the past? Your name does sound familiar to me for some reason. I've been here since 1988.

Anyhow, thanks for your time and your help. As always, I appreciate it a lot!!!
Carlos
0 Kudos