主题:win32ListView创建及使用给我弄破防了
HWND lv1 = CreateWindow(WC_LISTVIEW, _T(""), WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SHOWSELALWAYS, 0, 35, 300, 100, hwnd, (HMENU)listview1, NULL, NULL); DWORD a = GetLastError(); if (lv1 == NULL) { say(); } LVCOLUMN lvcol = { 0 }; lvcol.mask |= LVCF_WIDTH | LVCF_TEXT; lvcol.cx = 100; lvcol.pszText = (LPWSTR)_T("第0列"); //SendMessage(lv1, LVM_INSERTCOLUMN, 0, (LPARAM)&lvcol); ListView_InsertColumn(lv1, 0, &lvcol); a = GetLastError(); LVCOLUMN lvcol2 = { 0 }; lvcol2.mask |= LVCF_WIDTH | LVCF_TEXT | LVCF_FMT; lvcol2.cx = 100; lvcol2.pszText = (LPWSTR)_T("第1列"); lvcol2.fmt = LVCFMT_RIGHT; SendMessage(lv1, LVM_INSERTCOLUMN, 1, (LPARAM)&lvcol2); a = GetLastError(); LVITEM row_item = { 0 }; row_item.mask |= LVCF_TEXT; row_item.pszText = (LPWSTR)_T("111"); //ListView_InsertItem(lv1, &row_item); SendMessage(lv1, LVM_INSERTITEM, 0, (LPARAM)&row_item);a = GetLastError();
就这一段代码,createwindow成功了返回的不是null但错误码1407窗口类无效,但是上列表显示了,之后两个column插入正常,但都返回6句柄无效,row也是,但row还插入失败,真给我弄破防了,什么东西啊!半天搞不懂为啥。