I want to show the windows form as a pop up window that appear on the top of all the opened other application's windows
i have used Focus
method but it didn't work.
so i have tried :
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);
}
}
as mentioned in a previous question on SO Here
but i couldn't use it .
the right answer poster said "Basically, call ShowWindow() then SetForegroundWindow().
" but i didn't know what are the parameters for these methods
what exactly should i pass to the ShowWindow();
and the SetForegroundWindow(); methods??
any help?