Setting a wait cursor on a dialog using pure Win32
-
I know I can use CWaitCursor in MFC to do it, but I'm using Win32 and it's being a pain. I tried using SetCursor, but that fails because the DialogBox has an HCURSOR set in the class. And I don't want to change the class cursor, or I'd affect all other dialogs. Then I implemented WM_SETCURSOR, and that works fine. But however, when I move the mouse over child controls (buttons, list view, etc), the cursor changes back to normal until I go over the dialog again. My brain says I have to subclass all these controls, and implement my own WM_SETCURSOR for them, but that seems like a hassle. Is there an easier way?
-
I know I can use CWaitCursor in MFC to do it, but I'm using Win32 and it's being a pain. I tried using SetCursor, but that fails because the DialogBox has an HCURSOR set in the class. And I don't want to change the class cursor, or I'd affect all other dialogs. Then I implemented WM_SETCURSOR, and that works fine. But however, when I move the mouse over child controls (buttons, list view, etc), the cursor changes back to normal until I go over the dialog again. My brain says I have to subclass all these controls, and implement my own WM_SETCURSOR for them, but that seems like a hassle. Is there an easier way?
Note that you use CWaitCursor for activities which freeze UI. In this case, SetCursor should be enough. CWaitCursor is basically a wrapper over SetCursor calls. Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
-
Note that you use CWaitCursor for activities which freeze UI. In this case, SetCursor should be enough. CWaitCursor is basically a wrapper over SetCursor calls. Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
SetCursor doesn't work, because when I move the mouse, Windows sends a WM_SETCURSOR which basically rewrites my SetCursor call.
-
SetCursor doesn't work, because when I move the mouse, Windows sends a WM_SETCURSOR which basically rewrites my SetCursor call.
Just like I've posted in my first response, this shouldn't be a problem when you want to show wait cursor during some lenghty, UI-blocking operation. In this case, your app's message queue isn't serviced and code in user32.dll doesn't send WM_SETCURSOR. Or maybe you want to change the cursor to hourglass permanently? Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
-
Just like I've posted in my first response, this shouldn't be a problem when you want to show wait cursor during some lenghty, UI-blocking operation. In this case, your app's message queue isn't serviced and code in user32.dll doesn't send WM_SETCURSOR. Or maybe you want to change the cursor to hourglass permanently? Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
Ah yes I understand now. However, my program launches the work in numerous synchronized background threads. Therefore, the queue is still active! I think I'm going to have to subclass all the child controls unfortunately. But it won't be too hard.
-
Ah yes I understand now. However, my program launches the work in numerous synchronized background threads. Therefore, the queue is still active! I think I'm going to have to subclass all the child controls unfortunately. But it won't be too hard.
Todd Jeffreys wrote: But it won't be too hard Well, it's not too hard. The question is, however, what your users will think about clicking on edit control with hourglass cursor and moving the insertion point to the clicked location :) Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.