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. How to apply a Hand cursor to a Picture box

How to apply a Hand cursor to a Picture box

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
7 Posts 4 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.
  • S Offline
    S Offline
    snprani
    wrote on last edited by
    #1

    Hi How to apply a Hand cursor to a Picture box and its member variable is a CStatic control. Whenever i moved cursor on to that picture box it should display Hand cursor. My application is SDI application in which CView class is derived from CFormView. I have tried in this way but didn't get plz help me. m_Image.SetCursor(::LoadCursor(NULL,IDC_HAND)); //here IDC_HAND is not working i have given IDC_HELP. Where should i use this code in View class to display that cursor. Help me.

    C Mircea PuiuM 2 Replies Last reply
    0
    • S snprani

      Hi How to apply a Hand cursor to a Picture box and its member variable is a CStatic control. Whenever i moved cursor on to that picture box it should display Hand cursor. My application is SDI application in which CView class is derived from CFormView. I have tried in this way but didn't get plz help me. m_Image.SetCursor(::LoadCursor(NULL,IDC_HAND)); //here IDC_HAND is not working i have given IDC_HELP. Where should i use this code in View class to display that cursor. Help me.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      I think (I'm not sure), you have to activate the notify style of the CStatic (in the properties of the control). Then, go in the class wizzard and add a handler for the mouse move event of your control (it must have an ID different than IDC_STATIC). This handler function is in the view class. Then add your code for loading the cursor in this function.

      1 Reply Last reply
      0
      • S snprani

        Hi How to apply a Hand cursor to a Picture box and its member variable is a CStatic control. Whenever i moved cursor on to that picture box it should display Hand cursor. My application is SDI application in which CView class is derived from CFormView. I have tried in this way but didn't get plz help me. m_Image.SetCursor(::LoadCursor(NULL,IDC_HAND)); //here IDC_HAND is not working i have given IDC_HELP. Where should i use this code in View class to display that cursor. Help me.

        Mircea PuiuM Offline
        Mircea PuiuM Offline
        Mircea Puiu
        wrote on last edited by
        #3

        Hi, Assume CYourControl is the class implementing your image or whatever you are using, and TheParent is the class corresponding to the host of your control. Write the following code within the handler responding to the WM_SETCURSOR event:

        BOOL TheParent::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
        {
        // TODO: Add your message handler code here and/or call default
        CYourControl *pYC = ...... // get here the pointer to your control

        if ( pYC )
        {
        	if ( pWnd == pYC )
        	{
        		SetCursor(LoadCursor(NULL,IDC\_YOUR\_CURSOR));
        		return TRUE;
        	}
        }
        
        return TheParentBaseClass::OnSetCursor(pWnd, nHitTest, message);
        

        }

        IDC_HAND Windows is defined for NT 5.0 and later. You can create your own cursor. Do not forget that line returning TRUE! SkyWalker -- modified at 3:38 Friday 21st October, 2005

        E 1 Reply Last reply
        0
        • Mircea PuiuM Mircea Puiu

          Hi, Assume CYourControl is the class implementing your image or whatever you are using, and TheParent is the class corresponding to the host of your control. Write the following code within the handler responding to the WM_SETCURSOR event:

          BOOL TheParent::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
          {
          // TODO: Add your message handler code here and/or call default
          CYourControl *pYC = ...... // get here the pointer to your control

          if ( pYC )
          {
          	if ( pWnd == pYC )
          	{
          		SetCursor(LoadCursor(NULL,IDC\_YOUR\_CURSOR));
          		return TRUE;
          	}
          }
          
          return TheParentBaseClass::OnSetCursor(pWnd, nHitTest, message);
          

          }

          IDC_HAND Windows is defined for NT 5.0 and later. You can create your own cursor. Do not forget that line returning TRUE! SkyWalker -- modified at 3:38 Friday 21st October, 2005

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          nice mircea, and do u think, an else part is needed? i'm not sure. but luking at ut code, if ( pWnd == pYC ) { SetCursor(LoadCursor(NULL,IDC_YOUR_CURSOR)); return TRUE; } /* else // not needed? { SetCursor(LoadCursor(NULL,IDC_ARROW)); return TRUE; } */ if this sets changes the cursor the first time, then if we move on to the next control will this cursor stay in the same IDC_YOUR_CURSOR? dont it need to change to IDC_IDC_ARROW? plz teach me :) He is like a one-legged man in a bum kicking competition. -Novjot Sidhu --[v]--

          Mircea PuiuM 1 Reply Last reply
          0
          • E Eytukan

            nice mircea, and do u think, an else part is needed? i'm not sure. but luking at ut code, if ( pWnd == pYC ) { SetCursor(LoadCursor(NULL,IDC_YOUR_CURSOR)); return TRUE; } /* else // not needed? { SetCursor(LoadCursor(NULL,IDC_ARROW)); return TRUE; } */ if this sets changes the cursor the first time, then if we move on to the next control will this cursor stay in the same IDC_YOUR_CURSOR? dont it need to change to IDC_IDC_ARROW? plz teach me :) He is like a one-legged man in a bum kicking competition. -Novjot Sidhu --[v]--

            Mircea PuiuM Offline
            Mircea PuiuM Offline
            Mircea Puiu
            wrote on last edited by
            #5

            Hi, I send you by e-mail the same coding example I sent to snprani. Ok? SkyWalker

            E 1 Reply Last reply
            0
            • Mircea PuiuM Mircea Puiu

              Hi, I send you by e-mail the same coding example I sent to snprani. Ok? SkyWalker

              E Offline
              E Offline
              Eytukan
              wrote on last edited by
              #6

              thank u so much. He is like a one-legged man in a bum kicking competition. -Novjot Sidhu --[v]--

              Mircea PuiuM 1 Reply Last reply
              0
              • E Eytukan

                thank u so much. He is like a one-legged man in a bum kicking competition. -Novjot Sidhu --[v]--

                Mircea PuiuM Offline
                Mircea PuiuM Offline
                Mircea Puiu
                wrote on last edited by
                #7

                You are welcome :-) SkyWalker

                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