After porting some code from VC6 to VS2005, I've been trying to clean up
some code warnings and came across this ...
If I try to compile:
SetClassLongPtr ( ghWnd, GCLP_HCURSOR, hCursor );
I get an error: 'SetClassLongA' : cannot convert parameter 3 from 'HCURSOR'
to 'LONG'
Shouldn't this be 'HCURSOR' to 'LONG_PTR'?
So I try:
SetClassLongPtr ( ghWnd, GCLP_HCURSOR, (LONG) hCursor );
and get a warning:
'type cast' : pointer truncation from 'HCURSOR' to 'LONG'
SetClassLongPtr ( ghBorderWnd, GCLP_HCURSOR, (LONG_PTR) hCursor );
error : cannot convert parameter 3 from 'HCURSOR' to 'LONG' ??? Why is it
expecting a LONG parameter?
SetClassLongPtr ( ghWnd, GCLP_HCURSOR, (LONG)(LONG_PTR) hCursor );
The compiler is happy with this?!
I also run into the same sort of problems with SetWindowLong()
OldListProc = (WNDPROC) SetWindowLongPtr ( hList, GWLP_WNDPROC, (WNDPROC)
SubListProc );
'SetWindowLongA' : cannot convert parameter 3 from 'WNDPROC' to 'LONG'
OldListProc = (WNDPROC) SetWindowLongPtr ( hList, GWLP_WNDPROC, (LONG)
(WNDPROC) SubListProc );
pointer truncation from 'WNDPROC' to 'LONG'
OldListProc = (WNDPROC) SetWindowLongPtr ( hList, GWLP_WNDPROC, (LONG)
(LONG_PTR) (WNDPROC) SubListProc );
'type cast' : conversion from 'LONG' to 'WNDPROC' of greater size
Happy with the parameter now but why does it think that it's returning a
LONG??
OldListProc = (WNDPROC) (LONG_PTR) SetWindowLongPtr ( hList, GWLP_WNDPROC,
(LONG) (LONG_PTR) (WNDPROC) SubListProc );
This is now acceptable, but why should I have to tell the compiler that
SetWindowLongPtr() is supposed to return a LONG_PTR?
Not a huge problem for me, but is it a bug?
If it's not, then is help file wrong or not supply enough information?
Regards,
Ron Francis
www.RonaldFrancis.com
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Thanks Igor,
That's a very comprehensive answer.
I feel pretty stupid now, because I usually google before I ask questions
here, although I couldn't find your link.
Cheers.
Ron.