这个问题,在天网防火墙中也有这个问题,比如主窗口不是焦点时,弹出菜单,非要选一下菜单,才能消失, 解决这个问题的关键是. 在MYMENU.TrackPopupMenu(ID_MENU1); 之前加一句: SetForegroundWindow(); 这个函数的功能为: puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user.
2)
case WM_RBUTTONDOWN:
{
CMenu Menu;
Menu.LoadMenu( IDR_MENU_ICON );
CPoint point;
GetCursorPos( &point ); SetForegroundWindow(); Menu.GetSubMenu( 0 )->TrackPopupMenu( TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, this, NULL );
PostMessage( WM_USER, 0, 0 );
break;
}
解决这个问题的关键是.
在MYMENU.TrackPopupMenu(ID_MENU1);
之前加一句: SetForegroundWindow();
这个函数的功能为: puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user.