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. Getting the cursor to change

Getting the cursor to change

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • G Offline
    G Offline
    gordingin
    wrote on last edited by
    #1

    I am using SetCursor and LoadCursor to change the cursor. m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON)); m_hOldCursor = SetCursor(m_hCursor); I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change.... Anyone? Thanks Ralph

    B D 2 Replies Last reply
    0
    • G gordingin

      I am using SetCursor and LoadCursor to change the cursor. m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON)); m_hOldCursor = SetCursor(m_hCursor); I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change.... Anyone? Thanks Ralph

      B Offline
      B Offline
      basementman
      wrote on last edited by
      #2

      You need to handle the message WM_SETCURSOR via the virtual handler OnSetCursor. The function is called repeatedly, so it should be optimized. In this handler and in the OnMouseMove handler is where you would call SetCursor.  onwards and upwards...

      1 Reply Last reply
      0
      • G gordingin

        I am using SetCursor and LoadCursor to change the cursor. m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON)); m_hOldCursor = SetCursor(m_hCursor); I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change.... Anyone? Thanks Ralph

        D Offline
        D Offline
        De Nardis Andrea
        wrote on last edited by
        #3

        Try this code: BOOL CSystemTray::SetIcon(UINT nIDBigIcon, UINT nIDSmallIcon, CStatic *pWndList, int nListNumber) { ASSERT (!nListNumber || (NULL != pWndList)); m_hIcon = AfxGetApp()->LoadIcon(nIDBigIcon); m_hSmallIcon = AfxGetApp()->LoadIcon(nIDSmallIcon); ASSERT ((NULL != m_hIcon) && (INVALID_HANDLE_VALUE != m_hIcon)); ASSERT ((NULL != m_hSmallIcon) && (INVALID_HANDLE_VALUE != m_hSmallIcon)); if ((NULL == m_hIcon) || (INVALID_HANDLE_VALUE == m_hIcon) || (NULL == m_hSmallIcon) || (INVALID_HANDLE_VALUE == m_hSmallIcon)) return FALSE; CDialog::SetIcon (m_hIcon, TRUE); CDialog::SetIcon (m_hSmallIcon, FALSE); //Aggiornamento lista icone if (nListNumber && (NULL == pWndList)) return FALSE; int i; CStatic *pPt = pWndList; for (i = 0; i < nListNumber; i++, pPt++) { pPt->SetIcon (m_hIcon); } return TRUE; } where: protected: HANDLE m_hCompletion; HICON m_hSmallIcon; HICON m_hIcon; This works great. I did not test it with icons loaded from different modules neither with string-named resources (only index-named ones). Hope this help. Regards, Andrea

        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