问题描述
源程序如下:LRESULTCALLBACKTryOut(HWNDhDlg,UINTmessage,WPARAMwParam,LPARAMlParam){HWNDhWndList;LVCOLUMNcolumn;LVITEMitem={0};LVITEMvi;switch(message){caseWM_INITDIALOG:hWndList=::GetDlgItem(hDlg,IDC_LIST1);::SendMessage(hWndList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);column.mask=LVCF_TEXT|LVCF_FMT|LVCF_WIDTH|LVCF_SUBITEM;column.fmt=LVCFMT_CENTER;column.cx=100;column.pszText="filename";::SendMessage(hWndList,LVM_INSERTCOLUMN,0,(LPARAM)&column);column.cx=78;column.pszText="class";::SendMessage(hWndList,LVM_INSERTCOLUMN,1,(LPARAM)&column);//column可以显示//////////item//::SendMessage(hWndList,LVM_DELETEALLITEMS,0,0);/*item.mask=LVIF_TEXT|LVIF_PARAM;item.iItem=0;item.iSubItem=1;item.pszText=_T("ok001");::SendMessage(hWndList,LVM_INSERTITEM,0,(long)&item);*///////vi//vi.iSubItem=1;//vi.pszText=_T("ok001");//::SendMessage(hWndList,LVM_SETITEMTEXT,0,(long)&vi);//::MessageBox(hWndList,"ok",MB_OK,NULL);break;caseWM_COMMAND:if(LOWORD(wParam)==IDOK){EndDialog(hDlg,LOWORD(wParam));returnTRUE;}if(LOWORD(wParam)==IDCANCEL)//item加不上去,没有显示,愁死了大哥大姐帮帮忙呀{hWndList=::GetDlgItem(hDlg,IDC_LIST1);item.mask=LVIF_TEXT|LVIF_PARAM|LVIF_INDENT|LVIF_DI_SETITEM;item.iItem=0;item.iSubItem=1;item.pszText=_T("ok001");::SendMessage(hWndList,LVM_INSERTITEM,0,(long)&item);}break;}returnFALSE;}