I am using the minGW32 compiler. I created a ListView with a checkbox like this:
HWND hListView = CreateWindowExW(0, WC_LISTVIEWW, L"", WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_EDITLABELS, 10,10,500,500, hwnd, (HMENU)ID_LISTVIEW, GetModuleHandle(NULL), NULL); SendMessage(hListView, WM_SETFONT, (WPARAM) font, TRUE); ListView_SetExtendedListViewStyle(hListView, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_GRIDLINES/*LVSCW_AUTOSIZE_USEHEADER*/); lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT; lvc.fmt = LVCFMT_LEFT;
And I would like to check if any checkbox is checked. eg. If I check any checkbox, show me a message:
I use this WM_NOTIFY: case WM_NOTIFY: { switch (LOWORD(wParam)) { case ID_LISTVIEW: { switch (((LPNMHDR) lParam)->code) { case LVN_ITEMCHANGED : MessageBoxW( NULL, (LPCWSTR)lpMsgBuf, L"Error", MB_OK | MB_ICONERROR ); } break; } break; } break; } break;
But it all happened. When I click on an empty ListView area or just click on any item. But I would like to launch the message box ONLY when changing the checkbox.
source share