I have an MFC dialog application that processes certain messages in PreTranslateMessage. One of the ones I'm interested in is Ctrl+R. However, I am receiving this message when I click on another window (the code editor in Visual Studio 2010, notepad++, etc) and copy some text with Ctrl+C (or Ctrl+X). Note that it doesn't seem to happen with Ctrl+V, and is reproducable using both GetKeyState
and GetASyncKeyState
. The behavior is very confusing! To reproduce, create a basic MFC dialog in Visual Studio 10, add pretranslate as:
BOOL CPreTranslateTestDlg::PreTranslateMessage(MSG *pMsg)
{
if (GetKeyState(VK_CONTROL) & 0x8000 && pMsg->wParam == 'R')
{
return true;
}
return CDialogEx::PreTranslateMessage(pMsg);
}
put a breakpoint on return true;
, launch the dialog. Then go to your Visual Studio Code window, and Ctrl+C some text; your breakpoint will be hit.
Any ideas on why this might be happening?