Pass through the accelerator key until the dialog box is running.

We have a very large internal MFC application. It has a main window with a menu and hundreds of unique subwindows (without a menu) that appear on top of the main window (not all at the same time). These sub-settings are implemented as CDialog, but they are not implemented (via CreateWindow, rather than DoModal). Their parent is HWNDset to NULL.

Recently, we received a request for a function - to enable the operation of a separate menu accelerator from the main window, even if one of the subwindows is an active window. This will make sense from the user's point of view.

It can be pretty easily faked using the application keyboard hook by watching for this exact keystroke, but I was wondering if there is a cleaner way?

+4
source share
1 answer

You can also use RegisterHotKey()in your main window. This will have a side effect that the new hotkey activates, even if it is pressed in another application. You can get around this by comparing GetCurrentProcessId()withGetWindowThreadProcessId(GetForegroundWindow())

+1
source

All Articles