I have a window with a menu and an edit class handle. In the menu I have an Edit section with some options like cut, copy, paste, ecc.
I have defined 2 keyboard accelerators:
IDR_ACCELERATOR2 ACCELERATORS
BEGIN
"A", ID_EDIT_SALL, VIRTKEY, CONTROL, NOINVERT
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
END
CTRL + Z works, but CTRL + A doesn't.
In the WM_COMMAND
case I have this:
switch (LOWORD(wParam))
{
case ID_EDIT_CLEAR:
SendMessage(hwndEdit, WM_CLEAR, 0, 0);
break;
case ID_EDIT_COPY:
SendMessage(hwndEdit, WM_COPY, 0, 0);
break;
case ID_EDIT_CUT:
SendMessage(hwndEdit, WM_CUT, 0, 0);
break;
case ID_EDIT_PASTE:
SendMessage(hwndEdit, WM_PASTE, 0, 0);
break;
case ID_EDIT_SALL:
SendMessage(hwndEdit, EM_SETSEL, 0, -1);
break;
case ID_EDIT_UNDO:
SendMessage(hwndEdit, WM_UNDO, 0, 0);
break;
}
When I click on the menu option Select All
, the option works well, it does select all the text in the editor handle, but when I try to use the keyboard combination CTRL+A Windows makes that error sound (like when you try to delete words in an empty document)
Update: the message loop
BOOL msgCheck;
while ((msgCheck = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if (msgCheck == -1)
{
MessageBox(NULL, TEXT("Error!"), TEXT("Error"), MB_ICONERROR);
return -1;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
IDR_ACCELERATOR2
accelerator table and see what happens. – Jabberwockycase ID_EDIT_UNDO:
case, I bet it is not hit when you press Ctrl+Z. – Jabberwocky