【发布时间】:2013-03-15 20:34:06
【问题描述】:
我有一个处理 PreTranslateMessage 中某些消息的 MFC 对话框应用程序。我感兴趣的其中之一是 Ctrl+R。但是,当我单击另一个窗口(Visual Studio 2010 中的代码编辑器、notepad++ 等)并使用 Ctrl+C 复制一些文本(或Ctrl+X)。请注意,使用 Ctrl+V 似乎不会发生这种情况,并且可以使用 GetKeyState 和 GetASyncKeyState 重现。行为非常混乱!要重现,请在 Visual Studio 10 中创建一个基本的 MFC 对话框,将 pretranslate 添加为:
BOOL CPreTranslateTestDlg::PreTranslateMessage(MSG *pMsg)
{
if (GetKeyState(VK_CONTROL) & 0x8000 && pMsg->wParam == 'R')
{
return true;
}
return CDialogEx::PreTranslateMessage(pMsg);
}
在return true; 上设置断点,启动对话框。然后转到您的 Visual Studio Code 窗口,然后 Ctrl+C 一些文本;你的断点会被命中。
关于为什么会发生这种情况的任何想法?
【问题讨论】: