I've been looking into this and it seems that pointer to member functions are a 
strange lot.  The most important point for this discussion is to recognize that 
pointers to member functions are not pointers, and in fact the sizeof a pointer to a 
member function can vary.
(http://weblogs.asp.net/oldnewthing/archive/2004/02/09/70002.aspx)

There must be an easier way to solve my problem, because it must come up often.  I 
have a CListCtrl with quite a few items in it, and the data in the list control must 
be periodically updated.  Since the order of the items in the list can be changed 
through drag/drop, it's not so simple as to do a Get1() call for the first item in the 
list, Get2() for item 2, etc.
Of course I can still used SetItemData to save the original index of an item, and then 
do a lookup based on that original index number.  It just seems that there should be 
an easier, more elegant way to do it.  This is why I wanted to assign the address of 
the corresponding Get() with SetItemData.

-Jean

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Jason Teagle
> Sent: Friday, July 09, 2004 3:48 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [msvc] SetItemData to member function ptr
> 
> 
> > a quick look told me that I'm _not_ supposed to cast a function
> > pointer to a void*.  This matter is more complicated than I
> > thought; looks like I've got some reading to do :)
> 
> 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...
> 
> 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.
> 
> --
> Jason Teagle
> [EMAIL PROTECTED]
> 
> 
> 
> _______________________________________________
> msvc mailing list
> [EMAIL PROTECTED]
> See 
> http://beginthread.com/mailman/listinfo/msvc_beginthread.com 
> for subscription changes, and list archive.
> 

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

Reply via email to