I use the following code to bring an external window to the foreground, making it active:
public static extern int SetForegroundWindow (int hwnd);
This works fine unless the window is minimized. In that case, the taskbar button gets the focus but the window does not restore to normal or maximized.
I tried the ShowWindow(pId, SW_MAXIMIZE) and that does not work. Nor does ShowWindowLong as follow:
windowStyle = GetWindowLong(process.MainWindowHandle.ToInt32(), GWL_STYLE);
windowStyle = windowStyle ^ WS_MAXIMIZE; // Tried with OR(|) as well as XOR(^)
SetWindowLong(process.MainWindowHandle.ToInt32(), GWL_STYLE, windowStyle);