【发布时间】:2014-02-28 16:41:10
【问题描述】:
我正在尝试制作一个提供地震风格下拉 HUD 控制台的应用程序。我可以让它显示和隐藏窗口,但我不知道如何在显示后将其设置为活动窗口。我使用 Win API 调用来显示和隐藏窗口。我试过 SetForegroundWindow(IntPtr hWnd) 和 SetFocus(IntPtr hWnd) 无济于事。有人有想法么?
public void ShowApp()
{
IntPtr h = FindWindow(null, "C:\\Windows\\system32\\cmd.exe");
ShowWindow(h, SW_SHOW);
//EnableWindow(h, true);
isHidden = false;
// set focus to console window
SetForegroundWindow(h);
System.Diagnostics.Debug.WriteLine(h);
}
【问题讨论】: