Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Setting a wait cursor on a dialog using pure Win32

Setting a wait cursor on a dialog using pure Win32

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Todd Jeffreys
    wrote on last edited by
    #1

    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?

    T 1 Reply Last reply
    0
    • T Todd Jeffreys

      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?

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      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.

      T 1 Reply Last reply
      0
      • T Tomasz Sowinski

        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.

        T Offline
        T Offline
        Todd Jeffreys
        wrote on last edited by
        #3

        SetCursor doesn't work, because when I move the mouse, Windows sends a WM_SETCURSOR which basically rewrites my SetCursor call.

        T 1 Reply Last reply
        0
        • T Todd Jeffreys

          SetCursor doesn't work, because when I move the mouse, Windows sends a WM_SETCURSOR which basically rewrites my SetCursor call.

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          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.

          T 1 Reply Last reply
          0
          • T Tomasz Sowinski

            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.

            T Offline
            T Offline
            Todd Jeffreys
            wrote on last edited by
            #5

            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.

            T 1 Reply Last reply
            0
            • T Todd Jeffreys

              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.

              T Offline
              T Offline
              Tomasz Sowinski
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups