m_hForegroundWnd = ::GetForegroundWindow();
// temporarily make this dialog an activatable window
ModifyStyleEx(WS_EX_NOACTIVATE,0);
// make this dialog foreground
SetForegroundWindow();
我是重载了OnNcLButtonDown()和OnKillFocus()然后,在里面添加了代码 m_hForegroundWnd = ::GetForegroundWindow(); // temporarily make this dialog an activatable window ModifyStyleEx(WS_EX_NOACTIVATE,0); // make this dialog foreground SetForegroundWindow(); 但是效果不佳。每次都要点击n次