> I'm sure they only say that because it then loses its C++ type
> information; but as long as you cast it back to the correct type the
> other end when retrieving it, it should be no problem. There's no
> other way I can think of to store such information against a CListCtrl
> item otherwise...

The problem is that casting a member function pointer to a void pointer is
not portable.  It might work on a system, and don't work on another one.
Under Win32 with VC, it works (IIRC.)

> Well, OK, that's not true. I guess the DWORD set into the list could
> be an index into an array of pointers, e.g.:
>
> CPtrArray     pointerArray ;  // Example only!
>
> CSomeClass *pObject = GetThePtr();
> int iArrayIndex = pointerArray.Add(pObject);
> myListCtrl.SetItemData(iListIndex, iArrayIndex);
>
> Of course, my example CPtrArray would also lose the type info on the
> ptr, so you would substitute your favourite STL container or whatever.

I would prefer a std::map to preserve type information.  Something like a:

 typedef void (CMyClass::*FuncPtr)(int);
 typedef std::map< unsigned, FuncPtr > MapType;
 MapType map;
 // ...

-------------
Ehsan Akhgari

Farda Technology (http://www.farda-tech.com/)

List Owner: [EMAIL PROTECTED]

[ Email: [EMAIL PROTECTED] ]
[ WWW: http://www.beginthread.com/Ehsan ]

You had not yet sought yourselves: then you found me. So do all believers;
thus all belief matters so little.
-Thus Spoke Zarathustra, F. W. Nietzsche




_______________________________________________
msvc mailing list
[EMAIL PROTECTED]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription 
changes, and list archive.

Reply via email to