Im trying to make a show/hide window but no way to make work a show window when i hide it. I already read in many forums but no way to do it work, sone one can help???
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
//WORKING
private void button1_Click(object sender, EventArgs e)
{
int hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
if (pr.ProcessName == "notepad")
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
//NOT WORKING
private void button2_Click(object sender, EventArgs e)
ShowWindow(hWnd, SW_SHOW);