Click to See Complete Forum and Search --> : 'LONG' to 'WNDPROC'
David19
October 6th, 2009, 01:58 AM
i'm getting a warning when i try to subclass the listview control like:
WNDPROC OrigList = (WNDPROC) SetWindowLongPtr (hwndList, GWL_WNDPROC,
(__int3264)(LONG_PTR) ListProc) ;
SetWindowLongPtr returns a LONG and i need it to cast to WNDPROC.
warning C4312: conversion from 'LONG' to 'WNDPROC' of greater size
Ajay Vijay
October 6th, 2009, 02:07 AM
SetWindowLongPtr returns LONG_PTR and not LONG. There is no need to double typecast it.
David19
October 6th, 2009, 02:44 AM
Oh right, i confused it with SetWindowLong( ). double typecast ListProc?
Ajay Vijay
October 6th, 2009, 02:46 AM
By double-typecasting, I meant this (not casting to 'double'):(__int3264)(LONG_PTR) ListProc
David19
October 6th, 2009, 02:52 AM
thats what i really mean :)
David19
October 6th, 2009, 02:55 AM
if i don't double typecast ListProc, i get an another warning.
Ajay Vijay
October 6th, 2009, 02:59 AM
What warning?
'(LONG_PTR) ListProc' should suffice. What is the type of 'ListProc' ?
David19
October 6th, 2009, 03:05 AM
warning C4244: 'argument' : conversion from 'LONG_PTR' to 'LONG', possible loss of data
ListProc is defined as:
LRESULT CALLBACK ListProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam);
Ajay Vijay
October 6th, 2009, 04:54 AM
I see the weird complication in the function and the LONG_PTR. The symbol SetWindowLongPtr, eventually maps to SetWindowLong API, and takes LONG only. But LONG_PTR is type-defined with something else.
But you can still use only one typecasting to __int3264.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.