I am writing a simple notepad editor (configured for some additional functions) in win32 api. Editing management fills the application area and constantly focuses. I also need to handle some keyboard commands, such as Ctl-S. So I usually use the keyboard accelerator table to determine the Ctl-S key, and in my message loop I have TranslateAccelerator
while (GetMessage(&Msg,NULL,0,0)>0) { if (!TranslateAccelerator(Msg.hwnd,HAccel,&Msg)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } }
Now my problem is that since the edit window always has focus when the user types Ctl-S, I donβt get the WM_COMMAND message at all. (I understand that HIWORD of wParam will become 1 for a keyboard accelerator, but that is not a problem).
case WM_COMMAND: switch (LOWORD(wParam)) { ... case ID_CTL_S_PRESSED: {My code here} break; ... }
If I try the code without the Edit control, I will get the WM_COMMAND message above. So, how do I get the WM_COMMAND message for the keyboard accelerator when the edit control always has focus?
source share