我在UI CWinThread中使用TrackPopupMenuEx, CMonitor源自CWinThread
monitor_ = (CMonitor *)AfxBeginThread(RUNTIME_CLASS(CMonitor));
CMonitor :: InitInstance包含
m_pMainWnd = new CWnd();
m_pMainWnd->CreateEx(WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE | WS_EX_TOPMOST, AfxRegisterWndClass(CS_DBLCLKS),
NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_VISIBLE, 50, 50, 50, 50, NULL, NULL);
然后我做
SetForegroundWindow(AfxGetMainWnd()->m_hWnd);
auto popup_menu_flags = TPM_RETURNCMD | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_VERTICAL;
auto menu_item = TrackPopupMenuEx(menu, popup_menu_flags, point.x, point.y, AfxGetMainWnd()->m_hWnd, NULL);
DestroyMenu(menu);
PopupMenu显示正确,我可以使用鼠标选择菜单项。但是箭头键不起作用。
我已经使用Spy ++和m_pMainWnd获取WM_KEYUP,VK_DOWN的消息但没有任何反应。看不到WM_KEYDOWN。
我错过了什么?