程序入口时做了
icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
icc.dwICC = ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES;
InitCommonControlsEx (&icc);
初始化时做了
hList = CreateWindowEx (WS_EX_CLIENTEDGE, ListViewClass, NULL, WS_CHILD | WS_VISIBLE | LVS_SHAREIMAGELISTS | LVS_EDITLABELS, 0, 0, 0, 0, hWnd, NULL, hInst, NULL);
然后,以下是对ListView的原有的项做更名操作(其他操作没有列出)
switch (Msg)
{
case IDN_COMMAND)
switch (LOWORD(wParam))
{
case IDM_RENAME:
lvi.mask = LVIF_PARAM;
dwCnt = SendMessage (hList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
SendMessage (hList, LVM_GETITEMTEXT, (WPARAM)dwCnt, (LPARAM)&lvi);
SendMessage (v, LVM_EDITLABEL, lvi.iItem, 0);
break;
}
break
}
结果如期望所得,进入项目名称的编辑状态。
但是,对于新加入的项目操作
switch (Msg)
{
case IDN_COMMAND)
switch (LOWORD(wParam))
{
case IDM_CREATE:
dwCnt = SendMessage (hList, LVM_GETITEMCOUNT, 0, 0);
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
lvi.iItem = dwCnt;
lvi.iSubItem = 0;
lvi.lParam = 1;
lvi.cchTextMax = 18;
lvi.iImage = 1;
lvi.pszText = FileName;
lvi.state = LVIS_SELECTED | LVIS_FOCUSED;
lvi.stateMask = -1;
if ((dwCnt = SendMessage (hList, LVM_INSERTITEM, 0, (LPARAM)&lvi)) != -1)
SendMessage (hList, LVM_EDITLABEL, dwCnt, 0);
break;
}
break
}
项目是产生了,但进不了编辑状态。