函数:SetForegroundWindow
需要先设置当前窗口为系统活动窗口,之后,系统就会自动设置响应的操作,比如自动隐藏之类的。
HMENU menu = CreatePopupMenu();
AppendMenu(menu, MF_STRING, 2, strExit.c_str() );
::SetForegroundWindow(g_hMainWnd);
UINT cmd = TrackPopupMenu(menu, TPM_RETURNCMD|TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_hMainWnd, NULL);