我想实现的功能:
当我选择CListCtrl一行的时候,可以提示这一行的信息(MessageBox)

stu是个结构体定义:
struct stu
{
char name[15];
char id[2];
};item是我选择了哪一行m_list是一个CListCtrl定义的对象
GetItemData是方法struct stu *ss = (struct stu*)(m_list.GetItemData(item));

CString name1 ;
name1.Format("%s",ss->name);
MessageBox(name1);
为什么我打印出来的是空的?

解决方案 »

  1.   

    struct stu *ss = (struct stu*)(m_list.GetItemData(item));
    感觉这句不太对
    不如试试看能不能取到数据
    cstring strA;
    strA = m_list.GetItemData(item));
      

  2.   

    看看MSDN:CListCtrl::GetItemData
    DWORD GetItemData( int nItem ) const;Return ValueA 32-bit application-specific value associated with the specified item.ParametersnItemIndex of the list item whose data is to be retrieved.ResThis function retrieves the 32-bit application-specific value associated with the item specified by nItem. This value is the lParam member of theLVITEM structure, as described in the Platform SDK你的程序没报错已经不错啦,你定义的结构体是什么东西啊,MSDN都说了返回值是一个LVITEM结构,这个结构体在MSDN中也有说明啊
      

  3.   

    返回的是实际是LVITEM中的lParam成员变量,
    和你SetItemData()里面第二个函数是一样的。