Pelles C forum

C language => Windows questions => Topic started by: Jean-Pierre Leroy on March 28, 2018, 08:58:05 AM

Title: ListView control : how to detect Ctrl-A shortcut to select all the items
Post by: Jean-Pierre Leroy on March 28, 2018, 08:58:05 AM
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
Title: Re: ListView control : how to detect Ctrl-A shortcut to select all the items
Post by: TimoVJL on March 28, 2018, 02:37:11 PM
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");
}
}
}
}
}
Title: Re: ListView control : how to detect Ctrl-A shortcut to select all the items
Post by: Jean-Pierre Leroy on March 30, 2018, 05:23:34 PM
Thank you very much.

It works perfectly.

Regards,
Jean-Pierre