No, you understand correctly.

But, with my list as an example, I have 68 items in the list.  So I have to set each 
line in the list like this (or in a switch statement):
if (dwGetItemDataValue == 1)
        csNew = Get1();
else if (dwGetItemDataValue == 2)
        csNew = Get2();
else if (dwGetItemDataValue == 3)
        csNew = Get3();
etc. etc.  all the way to 68, very tedious... and think of how I have to rewrite the 
numbering if I insert a new list item in the middle of the list.

And it even gets more complicated because the number of items in my list varies.  
Sometimes it might be 68 items long, and sometimes it might be 22 (or other numbers) 
items long. So sometimes the 60th item in the list would use Get60() and at other 
times the 40th item in the list would use GetXX() (some other 'Get' function).

It just would make a lot more sense to assign a pointer to function or a pointer to 
member to each list item.


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Phil Daley
> Sent: Monday, July 12, 2004 1:15 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [msvc] SetItemData to member function ptr
> 
> 
> At 7/12/2004 12:13 PM, prosen wrote:
> 
>  >> 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.
>  >
>  >I think saving the original index is not that bad a 
> solution. I've done
>  >it before and it is easy to understand and easy to debug 
> and maintain.
> 
> I am not sure that I understand what the problem is.
> 
> I use SetItemData to store a value unique to the class 
> holding the data in 
> that row.
> 
> Then, whenever I get a call for updating a row's data, I use 
> that value to 
> get to the class and then return the appropriate member 
> variable holding 
> that item's piece of data.
> 
> Probably, I am misunderstanding some part of the problem.
> 
> Phil Daley          < AutoDesk >
> http://www.conknet.com/~p_daley
> 
> 
> 
> 
> _______________________________________________
> 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