Setting the cursor
-
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 -
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?? ØivindOriginal 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.
-
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.
-
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);