We have a very large in-house MFC app. It has a main window with a menubar, and hundreds of unique subwindows (without menubars) that display on top of the main window (not all simultaneously). These subwindows are implemented as CDialog
s but run modelessly (via CreateWindow
, not DoModal
). Their parent HWND
is set to NULL
.
We recently got a feature request--allow a particular menubar accelerator from the main window to work, even when one of the subwindows is the active window. It would make sense from a user perspective.
This could be faked pretty easily with an application-wide keyboard hook, watching for that exact keystroke, but I was wondering if there is a cleaner way?
You can as well use RegisterHotKey()
in your main window. That will have a side effect that the new hotkey will trigger even if pressed in a different application. You can work around that by comparing GetCurrentProcessId()
with GetWindowThreadProcessId(GetForegroundWindow())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With