- Clicking on rows does not tick/untick the checkboxes, you need to click on the checkbox itself
The style of row selection also isn't the one i'd like, I'd really like row highlighting like in vlc > preferences > hotkeys, e.g.:
Upon adding the LVS_EX_AUTOCHECKSELECT style:
The checkbox in header now appears, HDS_CHECKBOXES had no effect.
Clicking on a row ticks the checkbox - good
However, problems:
- Clicking again on a row does not untick a checkbox. Should I forget this style and hard code it myself by detecting click events...?
- ****BIG PROBLEM**** The check boxes have all disappeared. They reappear for a single row when hovering over that row. If you tick a checkbox, and move away from the row, the checkbox disappears, moving back it reappears, but unticked. If you select a row, the ticked checkbox remains visible and ticked, until you select another row.
I could really do with some pointers on how to fix this, there are too many variables from my point of view :(
class LinkPeopleWindow
{
public:
static TCHAR* tmp[];
private:
HWND hListViews[1]; // array of listviews
protected:
static TCHAR* colHeaders[]; // List View column headings (NOTE, can NOT be const, incompatable type for LVCOLUMN pszText!)
};
TCHAR* LinkPeopleWindow::colHeaders[] = { _T("ID"), _T("Name") }; //NOTE, can NOT be const, incompatable type for LVCOLUMN pszText!
TCHAR* LinkPeopleWindow::tmp[] = { _T("a"), _T("1"), _T("Example Example Example Example") };
case WM_NOTIFY:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case ID_CTRL_LNKPPL_LV:
switch (((LPNMHDR) lParam)->code)
{
case LVN_GETDISPINFO:
NMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam;
switch (plvdi->item.iSubItem)
{
case 0:
//plvdi->item.pszText = LinkPeopleWindow::tmp[0];
break;
case 1:
plvdi->item.pszText = LinkPeopleWindow::tmp[1];
break;
case 2:
plvdi->item.pszText = LinkPeopleWindow::tmp[2];
break;
default:
break;
}
return 0;
}
break;
default:
break;
}
break;
#include <commctrl.h> is present in stdafx.h
InitCommonControls(); in _tWinMain()
ComCtl32.Lib dragged and dropped into project from C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib
Question
+theblazingangel MVC
I'm having some problems getting a listview to behave properly
Using the following styles I get the following:
LVS_EX_CHECKBOXES | HDS_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP
Problems:
- No checkbox in header
- Clicking on rows does not tick/untick the checkboxes, you need to click on the checkbox itself
The style of row selection also isn't the one i'd like, I'd really like row highlighting like in vlc > preferences > hotkeys, e.g.:
Upon adding the LVS_EX_AUTOCHECKSELECT style:
The checkbox in header now appears, HDS_CHECKBOXES had no effect.
Clicking on a row ticks the checkbox - good
However, problems:
- Clicking again on a row does not untick a checkbox. Should I forget this style and hard code it myself by detecting click events...?
- ****BIG PROBLEM**** The check boxes have all disappeared. They reappear for a single row when hovering over that row. If you tick a checkbox, and move away from the row, the checkbox disappears, moving back it reappears, but unticked. If you select a row, the ticked checkbox remains visible and ticked, until you select another row.
I could really do with some pointers on how to fix this, there are too many variables from my point of view :(
Some code:
this->hListViews[0] = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T(""), LVS_REPORT | WS_CHILD | WS_VISIBLE, 15, 17, 264, 260, this->hwnd, (HMENU)ID_CTRL_LNKPPL_LV, GetModuleHandle(NULL), NULL); SendMessage(this->hListViews[0], LVM_SETEXTENDEDLISTVIEWSTYLE, (WPARAM)(DWORD) LVS_EX_CHECKBOXES | HDS_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP | LVS_EX_AUTOCHECKSELECT, (LPARAM)(DWORD) LVS_EX_CHECKBOXES | HDS_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP | LVS_EX_AUTOCHECKSELECT); // extended styles (must be sent as a message!) LVCOLUMN col1, col2, col3; col1.fmt = col2.fmt = col3.fmt = LVCFMT_LEFT; col1.mask = LVCF_FMT | LVCF_WIDTH; col2.mask = col3.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; col1.cx = 30; col2.cx = 40; col3.cx = 172; col2.pszText = LinkPeopleWindow::colHeaders[0]; col3.pszText = LinkPeopleWindow::colHeaders[1]; ListView_InsertColumn(this->hListViews[0], 0, &col1); ListView_InsertColumn(this->hListViews[0], 1, &col2); ListView_InsertColumn(this->hListViews[0], 2, &col3); // Populate list view LVITEM *items[20]; for (int i=0; i < 20; i++) { items[i] = new LVITEM; items[i]->mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; items[i]->iItem = i; items[i]->iSubItem = 0; items[i]->state = 0; items[i]->stateMask = 0; items[i]->lParam = (LPARAM) &LinkPeopleWindow::tmp; items[i]->pszText = LPSTR_TEXTCALLBACK; // sends an LVN_GETDISP message. SendMessage(this->hListViews[0], LVM_INSERTITEM, (WPARAM)0, (LPARAM)items[i]); }class LinkPeopleWindow { public: static TCHAR* tmp[]; private: HWND hListViews[1]; // array of listviews protected: static TCHAR* colHeaders[]; // List View column headings (NOTE, can NOT be const, incompatable type for LVCOLUMN pszText!) };TCHAR* LinkPeopleWindow::colHeaders[] = { _T("ID"), _T("Name") }; //NOTE, can NOT be const, incompatable type for LVCOLUMN pszText! TCHAR* LinkPeopleWindow::tmp[] = { _T("a"), _T("1"), _T("Example Example Example Example") };case WM_NOTIFY: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case ID_CTRL_LNKPPL_LV: switch (((LPNMHDR) lParam)->code) { case LVN_GETDISPINFO: NMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam; switch (plvdi->item.iSubItem) { case 0: //plvdi->item.pszText = LinkPeopleWindow::tmp[0]; break; case 1: plvdi->item.pszText = LinkPeopleWindow::tmp[1]; break; case 2: plvdi->item.pszText = LinkPeopleWindow::tmp[2]; break; default: break; } return 0; } break; default: break; } break;#include <commctrl.h> is present in stdafx.h
InitCommonControls(); in _tWinMain()
ComCtl32.Lib dragged and dropped into project from C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib
Win 7 x64 RTM; VC9 express edition; windows sdk v7 rtm; C++; win32; 32-bit application (currently)
Link to comment
Share on other sites
4 answers to this question
Recommended Posts