我想将窗口窗体显示为一个弹出窗口,该窗口出现在我使用过的所有打开的其他应用程序窗口的顶部,Focus
但它不起作用。所以我试过:
using System.Diagnostics;
using System.Runtime.InteropServices;
// Sets the window to be foreground
[DllImport("User32")]
private static extern int SetForegroundWindow(IntPtr hwnd);
// Activate or minimize a window
[DllImportAttribute("User32.DLL")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int SW_SHOW = 5;
private const int SW_MINIMIZE = 6;
private const int SW_RESTORE = 9;
private void ActivateApplication(string briefAppName)
{
Process[] procList = Process.GetProcessesByName(briefAppName);
if (procList.Length > 0)
{
ShowWindow(procList[0].MainWindowHandle, SW_RESTORE);
SetForegroundWindow(procList[0].MainWindowHandle);
}
}
如上一个关于 SO Here的问题所述,
但我无法使用它。正确答案海报说“ Basically, call ShowWindow() then SetForegroundWindow().
”但我不知道这些方法的参数是什么
我究竟应该传递给 ShowWindow();
SetForegroundWindow(); 方法??有什么帮助吗?