開いている他のすべてのアプリケーションのウィンドウの上部に表示されるポップアップウィンドウとしてウィンドウフォームを表示したいのですが、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()に正確に何を渡す必要が ありますか。メソッド?? 何か助けはありますか?