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 the cursor

Setting the cursor

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 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.
  • D Offline
    D Offline
    dolph_loe
    wrote on last edited by
    #1

    I use the following code to set the cursor of a window: HCURSOR cursor = theApp.LoadStandardCursor(IDC_ARROW); SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG) cursor); The problem is that I get the following compiler warning: warning C4311: 'type cast' : pointer truncation from 'HCURSOR' to 'LONG' How do I do this the right way?? Øivind

    B 1 Reply Last reply
    0
    • D dolph_loe

      I use the following code to set the cursor of a window: HCURSOR cursor = theApp.LoadStandardCursor(IDC_ARROW); SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG) cursor); The problem is that I get the following compiler warning: warning C4311: 'type cast' : pointer truncation from 'HCURSOR' to 'LONG' How do I do this the right way?? Øivind

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

      Original function is: ULONG_PTR SetClassLongPtr( HWND hWnd, int nIndex, LONG_PTR dwNewLong ); That mean the you have poenter on cursor and need write: SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) &cursor); HCURSOR is "typedef unsigned int HCURSOR" but you need poenter on address.

      D 1 Reply Last reply
      0
      • B Branislav

        Original function is: ULONG_PTR SetClassLongPtr( HWND hWnd, int nIndex, LONG_PTR dwNewLong ); That mean the you have poenter on cursor and need write: SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) &cursor); HCURSOR is "typedef unsigned int HCURSOR" but you need poenter on address.

        D Offline
        D Offline
        dolph_loe
        wrote on last edited by
        #3

        With your code, I don't get any warnings, but the cursor doesn't change.. =( SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) &cursor);

        D 1 Reply Last reply
        0
        • D dolph_loe

          With your code, I don't get any warnings, but the cursor doesn't change.. =( SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) &cursor);

          D Offline
          D Offline
          dolph_loe
          wrote on last edited by
          #4

          Weee! I got it right. I only needed to cast the cursor to (LONG_PTR) and not reference it: SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) cursor);

          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