column.pszText = _T("Grade");
column.iSubItem = 3;
m_ListCtl.InsertColumn(3,&column);
column.cx = 55;
column.pszText = _T("Room");
column.iSubItem = 4;
m_ListCtl.InsertColumn(4,&column);
column.cx = 80;
column.pszText = _T("Tel");
column.iSubItem = 5;
m_ListCtl.InsertColumn(5,&column);
BOOL CReceiverDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
switch (pCopyDataStruct->dwData) { // 接收到的是CString类型
case STRING:
m_szData += (LPCSTR)(pCopyDataStruct->lpData);
UpdateData(FALSE);
break;
case STUDENT: // 接收到的是Student类型
CString id,name,room,tel;
UINT age,grade;
CString str;
Student* pStu = (Student*)(pCopyDataStruct->lpData);
id = pStu->ID;
name = pStu->Name;
room = pStu->Room;
tel = pStu->Tel;
age = pStu->Age;
grade = pStu->Grade;
LVITEM item;
// 把接收到的数据显示到ListCtrl控件上
item.mask = LVIF_TEXT;
int n = m_ListCtl.GetItemCount();
item.iItem = n;
item.iSubItem = 0;
item.pszText = id.GetBuffer(id.GetLength());
id.ReleaseBuffer();
m_ListCtl.InsertItem(&item);
m_ListCtl.SetItemText(n,1,name);
str.Format("%d",age);
m_ListCtl.SetItemText(n,2,str);
str.Format("%d",grade);
m_ListCtl.SetItemText(n,3,str);
m_ListCtl.SetItemText(n,4,room);
m_ListCtl.SetItemText(n,5,tel);
UpdateData(FALSE);
//delete pStu;
break;
}
// return CDialog::OnCopyData(pWnd, pCopyDataStruct);
return TRUE;
}