Author Message

Hello there!

Is someone knows of any problem using CWaitCursor under Visual C++ version
It seems to fail even if I use CWinApp::DoWaitCursor (1) or

It should be so simple and yet...

    Udi Sherf

Sun, 30 Sep 2001 03:00:00 GMT  
DoWaitCursor will only work if you are not allowing any messages to be
processed as your application will turn the mouse cursor back into an arror
(or whatever) if you do any processing of background messages.  I've found
that handling the cursor using WM_SETCURSOR for a window works better.  You
can change the state of the cursor easy enough by setting a flag that tells
the OnSetCursor() function what cursor is currently appropriate.  If you
allow background processing, for example, you will want the combination
arrow/hourglass type cursor whereas if you are totally tying up the window
you will want to do an hourglass.

I made up a function in my applications called BusyCursor() that I all to
just change the state variable and pump a message.  Another thing that
happens on occasion is the process gets done and the cursor doesn't change
until the mouse is moved.  I found this annoying because users were looking
at the screen thinking things weren't completed.  I fixed the problem by
just moving the mouse (using the program) the the same location where it is
already located (sounds dumb I know...)...  It looks like this:

// This function will restore the cursor to the application's standard
// It uses the Get and SetCursorPos functions to simulate moving the cursor
so it will
// actually change.
HCURSOR RestoreCursor()
 HCURSOR hCursor;
 POINT lppt; /* address of structure for cursor position */
 hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
 SetCursorPos(lppt.x, lppt.y);
 return hCursor;


Another way to do the BusyCursor() idea is just to force the issue like

void CMyApp::BusyCursor(BOOL bOn)
  m_hCursor = AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING);
  m_hCursor = RestoreCursor();





>Hello there!

>Is someone knows of any problem using CWaitCursor under Visual C++ version
>It seems to fail even if I use CWinApp::DoWaitCursor (1) or

>It should be so simple and yet...

>    Udi Sherf

Mon, 01 Oct 2001 03:00:00 GMT  

I had no problem creating a wait cursor. I used:

    CWaitCursor Wait;

This makes the cursor appear as an hourglass.
The CWaitCursor object has a member function CWaitCursor::Restore(), which
restores the wait cursor in case any dialog box or message box has altered the
cursor in the mean time.

< 1K Download

Mon, 01 Oct 2001 03:00:00 GMT  

Have you tried calling CWaitCursor's Restore() function?

Charles Steinhardt[MVP]
(To Email: remove NO_SPAM_NO from return address)

Sat, 06 Oct 2001 03:00:00 GMT  
 [ 4 post ] 

 Relevant Pages 

1. CWaitCursor in a thread in an AX Control

2. CWaitCursor in a dialog?

3. CWaitCursor

4. CWaitCursor

5. CWaitCursor

6. Question About CWaitCursor

7. CWaitCursor

8. CWaitCursor

9. cwaitcursor problems???

10. Problem with CWaitCursor in an ATL .dll

11. Why doesn't a mouse hook work with CWaitCursor ?

12. CWaitCursor in a CWnd created in a service ???? CAN IT BE DONE


Powered by phpBB® Forum Software