Can't change cursor state 
Author Message
 Can't change cursor state

I set the cursor to IDC_WAIT when user click a button, but
it change back to arrow when i move my mouse, why?


Sun, 24 Oct 2004 10:16:11 GMT  
 Can't change cursor state

Quote:

>I set the cursor to IDC_WAIT when user click a button, but
>it change back to arrow when i move my mouse, why?

Whenever you move the mouse, the window containing the cursor receives
WM_SETCURSOR messages. Thus, if you change the cursor and resume
processing messages, the cursor tends to get reset. Normally, you'll
use CWaitCursor during a lengthy operation that doesn't process
messages, but this won't work if you resume your message loop. I've
handled this by defining an "application state" variable, which
indicates whether the app is "waiting" (IDC_WAIT), "working"
(IDC_APPSTARTING), or "idle" (normal). I handle WM_SETCURSOR in my
mainframe class and use SetCursor to set the appropriate cursor; the
normal case defers to the base class. That's the basic idea, anyway.

--
Doug Harrison
Microsoft MVP - Visual C++
Eluent Software, LLC
http://www.eluent.com
Tools for VC++, VS.NET, and Windows



Sun, 24 Oct 2004 10:45:16 GMT  
 Can't change cursor state
Hi,
An additional note: if you just want to use the wait cursor, try  
BeginWaitCursor() and EndWaitCursor() functions.

M. Nouryan


Quote:

> >I set the cursor to IDC_WAIT when user click a button, but
> >it change back to arrow when i move my mouse, why?

> Whenever you move the mouse, the window containing the cursor receives
> WM_SETCURSOR messages. Thus, if you change the cursor and resume
> processing messages, the cursor tends to get reset. Normally, you'll
> use CWaitCursor during a lengthy operation that doesn't process
> messages, but this won't work if you resume your message loop. I've
> handled this by defining an "application state" variable, which
> indicates whether the app is "waiting" (IDC_WAIT), "working"
> (IDC_APPSTARTING), or "idle" (normal). I handle WM_SETCURSOR in my
> mainframe class and use SetCursor to set the appropriate cursor; the
> normal case defers to the base class. That's the basic idea, anyway.



Sun, 24 Oct 2004 22:22:51 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. how to change the 'cursor'

2. changing control's state from outside dialog

3. Seems no way can change IE's fullscreen size/position or state

4. CRecordset::Requery doesn't change cursor buffer

5. Why the cursor didn't change?

6. how to change richedit context menu 's mouse cursor type

7. dynamically change cursor's hot spot

8. Change mouse's cursor

9. Can't change cursor in MFC app

10. Cursor won't change

11. Changing a Control's Cursor

12. Changing a view's cursor

 

 
Powered by phpBB® Forum Software