What is the default cursor for a thread?


When we looked at the process by which the cursor is set, we neglected to discuss the case where nobody bothers to set the cursor. What is the ultimate default cursor?

Let's write a program that refuses to set the cursor. Take the scratch program and add these lines:

BOOL OnSetCursor(HWND hwnd, HWND hwndCursor,
                 UINT codeHitTest, UINT msg)
{
  return TRUE;
}

   HANDLE_MSG(hwnd, WM_SETCURSOR, OnSetCursor);

What we did was make the window explicitly refuse to set the cursor by making it do nothing and return TRUE, which means, "It's all good. I set the cursor!" (Liar, liar, pants on fire.)

Run this program, move the cursor over the window, and what do you get?

The hourglass.

Now, this is clearly some sort of pathological case, where there is a thread that covers its ears and hums whenever the window manager asks it to specify a cursor. But you can end up in this case unintentionally, and in fact there's a good chance that you've seen it happen. Just write an application that blocks the UI thread during startup. Take a fresh scratch program and add a different line of code:

        ShowWindow(hwnd, nShowCmd);

        Sleep(5000);

        while (GetMessage(&msg, NULL, 0, 0)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

Here, we're simulating a program that hangs its UI thread during initialization. During that initial five-second delay, the program has yet to pump any messages, so it hasn't yet received the WM_MOUSE­MOVE or WM_NC­MOUSE­MOVE message that would normally trigger the WM_SET­CURSOR message. All the window manager can do is show the default cursor.

That's why the default cursor is an hourglass.

Comments (21)
  1. kinokijuf says:

    Pre-emptive snarky comment: Why is the hourglass circular in the “Aero” theme?

  2. Henke37 says:

    Because it is technically not called the hourglass cursor.

  3. pagefault says:

    in .Net it's called Wait-Cursor.

  4. Miff says:

    Yeah, the term "hourglass" is one of those misnomers now, it's technically the wait cursor (IDC_WAIT or Cursors.WaitCursor for .NET types like myself). The Mouse control panel also calls it the busy cursor.

  5. Veltas says:

    kinokijuf: Because it looks good.  And when people got Vista nobody complained about the new cursor scheme, so was apparently visually intuitive too.

    Henke37: Even if it was, they could just go ahead and change it to whatever they wanted.  And, in fact, I think everyone I knew pre-Vista called it the 'hourglass'.  Seems like you are talking about either the macro that refers to it or the control panel name for it, in which case I retort with a previous article!  blogs.msdn.com/…/10416464.aspx

  6. Ivo says:

    This post has been sitting in the queue from before Vista. That's why it says "hourglass".

  7. Muzer says:

    Veltas: And I counter with blogs.msdn.com/…/54831.aspx (the whole thing about calling things by their actual names).

    Of course, if somewhere officially calls it the hourglass cursor I'll take that back ;)

  8. Veltas says:

    Muzer: Touché (or however it's spelt, only hear it said).

    But I think that's more important when trying to talk to a user about an important application (like the taskbar).  I suppose if I was talking to a user about this stuff I'd say the 'busy cursor' because that describes it perfectly (and according to Miff that's actually its God-given name).  Maybe the linked article would have been a more appropriate retort to someone calling it the 'wait' cursor, although not so much since it's still obvious what that means (unlike NT 6.2, for instance).

    I actually go ahead and suggest calling it the 'busy' cursor is good practise because it's always good practise to use the same terminology that your users will use.

  9. Muzer says:

    Indeed. I've always called it the busy cursor (and that's what it is (used to be) labelled as in the GUI). I do pretty much agree with you ;)

  10. Veltas says:

    Actually I just double-checked by bringing up Control Panel and it might actually be better to refer to the cursor as the pointer because that's what it's called there.  This is probably a good idea, since a cursor is anything that hovers and is used to mark a position, such as the line cursor when you type.

    Oh what fun conversations I have on here. xD

  11. Ken White says:

    @Muzer: > Of course, if somewhere officially calls it the hourglass cursor I'll take that back ;)

    The documentation for LoadCursor officially defines IDC_WAIT with a note that says Hourglass. Is that close enough? :-) msdn.microsoft.com/…/ms648391%28v=vs.85%29.aspx

  12. Jonathan says:

    I've heard Vista's wait cursor called "Bagel".

  13. Muzer says:

    @Ken White: Hah, close enough.

    (Is this perhaps something that's used more in Microsoft than out, perhaps, or have I just met nobody who happens to call it the hourglass? ;))

  14. Professor Yaffle says:

    Hourglass?  Nonsense!  It's plainly an egg timer.

  15. @Jonathan: I can beat that – one of my co-workers calls it the 'minty blue sphincter' :D

  16. Nick says:

    Raymond – I've noticed now that several comments I've posted over the last few weeks have either never been approved or have been deleted.  The comment on this post was an innocuous joke about the old dinosaur cursor set.  What was wrong with it?  Or do comments sometimes just not get posted?

    [Never saw it. It got filtered out before it reached me. -Raymond]
  17. Joshua says:

    [Never saw it. It got filtered out before it reached me. -Raymond]

    :-(

  18. lucidfox says:

    Why is there a WM_SETCURSOR message in the first place? Why not just keep a cursor reference associated with the window and only change it when explicitly requested (like it is done in almost all modern GUI frameworks)?

    [Windows followed the "Don't save anything you can recalculate" principle to save memory. Also, it lets you do things like "parent window overrides cursor for all children" and "child window defers cursor choice to parent." Plus of course that many apps use different cursors depending on where in the window you are. (Insertion point if over editable text, hand if over a link, etc.) -Raymond
  19. Clipboarder Gadget says:

    @lucidfox This is probably from a time when it was cheaper to just send a message than to waste 2-4 bytes per window.

  20. 640k says:

    @nick: The blog software (written by Raymond) has serious flaws, most irritating is ofcourse the session time-out bug which eats all comments posted after more than a few minutes after the page is loaded.

  21. Nick says:

    [Never saw it. It got filtered out before it reached me. -Raymond]

    I see.  Perhaps the magic filter didn't like the hyperlink I included, but whatever the cause a filter that deletes comments without interaction or notification seems to be a pretty poor design — or at least a good way to curb commenting.  I don't think this used to be a problem; you might consider it off if you're able.

    (And I'm sorry, I know you don't like people complaining about the blog software)

Comments are closed.

Skip to main content