NO

Author Topic: ListView control : how to detect Ctrl-A shortcut to select all the items  (Read 872 times)

Offline Jean-Pierre Leroy

  • Member
  • *
  • Posts: 7
I have a listview control and I would like to detect the Ctrl-A shortcut to select all the items.

Any ideas how to do that ?

Thanks,
Jean-Pierre

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1827
check WM_NOTIFY code
Code: [Select]
void OnNotify(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
if (wParam == 4001) { // Listview Id
if (((NMHDR*)lParam)->code == LVN_KEYDOWN) {
if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_A) {
SHORT nState = GetKeyState(VK_CONTROL);
if (nState & 0x80) {
SetWindowText(hWnd, "Ctrl-A");
}
}
}
}
}
May the source be with you

Offline Jean-Pierre Leroy

  • Member
  • *
  • Posts: 7
Thank you very much.

It works perfectly.

Regards,
Jean-Pierre