为何ListView_Insertcolumn 无法显示
我用Win32 SDK 写了一个程序,
创建了WC_LISTVIEW 后用ListView_InsertColumn()添加一列。
宏 提示添加成功,但运行后却无法正确显示,只有一片白色。
下面是代码:
case WM_CREATE:
hlist=CreateWindowEx(0,WC_LISTVIEW,NULL,WS_CHILD|WS_VISIBLE|LVS_LIST,0,0,200,400,hwnd,(HMENU)1024,ghInst,NULL);
if(hlist==NULL){
MessageBox(hwnd,"Failed to Create Listview","Error",MB_OK);
}
else{
MessageBox(hwnd,"Success to Create ListView ","Success",MB_OK);
}
lvc.fmt=LVCFMT_RIGHT;
lvc.mask=LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;
lvc.pszText="haha ha ";
lvc.cchTextMax=9;
lvc.cx=50;
if(ListView_InsertColumn(hlist,1,&lvc)==-1){
MessageBox(hwnd,"Failed to InsertColumn","Error",MB_OK);
}else{
MessageBox(hwnd,"Success to InsertColumn","Success",MB_OK);
}
请问为什么不行呢?怎样正确的添加一列呢?(必须在Win32 下实现,别提MFC ,MFC谁都会 。)
[解决办法]
把 LVS_LIST 改成 LVS_REPORT
[解决办法]
LVS_List要设置Report风格才可以的,最好察看一下MSDN里的相关SDK说明。