WaitCursor query

N

Neville Lang

Hi all,

I am currently developing a CF project in C# and currently working on a
desktop supporting EXE, also in C#. Using RAPI and the CeFindFirstFile /
CeFindNextFile, I am counting up the number of files with a specific
extension. This takes a bit of time and I simply wanted to display a
WaitCursor on the desktop. While I did not have any problems with cursors on
the CF, I cannot get a wait cursor to display on a window on the desktop
just before the RAPI functions take effect. I am using:

Cursor.Current = Cursors.WaitCursor;

this.lblFileBackup.Text = "Getting all chart files from the Pocket
PC...";

this.btnOK.Enabled = false;

Application.DoEvents(); // Added this in case but no
affect


and have also used
Cursor.Current = Cursors.WaitCursor;

Cursor.Show();

...
...

but still when the app runs, the default cursor (pointer) continues to
display. Is there anything I am missing in the code on the desktop side?

Regards,
Neville Lang
 
S

Stephanie Conroy [MSFT]

I gave this a quick try, and found that I couldn't change the cursor unless
I used a specific control's cursor property. So I created a blank panel
control to cover the entire form window and changed its cursor. Maybe this
solution will work for you.

I will investigate to see if there is a better resolution to this issue.

Stephanie Conroy
Visual Basic tester
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex Feinman [MVP]

Unlike CF the Cursors on the desktop are not global. You need to assign
required Cursor to the Cursor property of the application's main form
 
A

Alex Feinman [MVP]

Hit send too fast...
The reason it works differently on the desktop is that desktop controls
support ambient properties, i.e. if you have not specified cursor for a
control explicitly, it will attempt to get the value from its parent control
(form)
 
N

Neville Lang

Dear Alex and Stephanie,

I changed -
Cursor.Current = Cursors.WaitCursor;
to
this.Cursor = Cursors.WaitCursor;

and it still did not give a WaitCursor. The form I am using is not full
screen but does sit in the middle of the screen. I am using Debug mode to
test under VS .NET 2003 and when I move the mouse cursor out of my form
window to the background of VS .NET 2003 it does change to an "I" cursor and
when I move it back into the my form, in reverts to a regular pointer again,
even though I set it to the WaitCursor. Is there something else I should be
doing?

Thanks Alex for the additional information of why we need to use the form's
cursor property, it is handy to know.

Regards,
Neville Lang
 
A

Alex Feinman [MVP]

The cursor might not be displayed properly if your form is not processing
events - is inside a blocking call. If you are performing a blocking
operation that spans over 500 ms, consider moving it into a separate thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top