I have a standard message loop:
MSG msg = {};
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
I’d like to process WM_KEYDOWN
and its generated WM_CHAR
event together — is this possible? My app first sees if it has a registered keybinding for WM_KEYDOWN
, but if not, it should fall through and be interpreted as WM_CHAR
.
Due to the separated nature of the queue, I’m not sure how to recognize which message pairs with what. There’s no guarantee a WM_KEYDOWN
generates a WM_CHAR
. A WM_CHAR
could also be standalone (e.g., IME input)!
An equally good alternative would be a way to remove the WM_CHAR
from the queue in the WM_KEYDOWN
body (or just recognize and ignore it).
For example, if the user presses “enter”:
WM_KEYDOWN
withVK_RETURN
is generated.WM_CHAR
withr
is generated.- Say my app processes
VK_RETURN
.WM_CHAR
event should be removed or ignored.