大家好,我是新手,提个问题,高手帮帮忙,关于win32 应用程序listctrl控件,没办法插入数据的问题
源程序如下:LRESULT CALLBACK TryOut(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hWndList ;
LVCOLUMN column ;
LVITEM item = {0} ;
LVITEM vi ;
switch (message)
{
case WM_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 = " file name" ;
::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;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK )
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
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;
}
return FALSE ;
}
补充:.NET技术 , 组件/控件开发