ok, the title is quite long and should report a problem that I am facing.
Here is the code that is minimized for the icon:
void MainFormResize(object sender, EventArgs e) { if (WindowState == FormWindowState.Minimized) { this.Hide(); this.ShowInTaskbar = false; } }
When the program is already open in the sys tray, and still someone wants to open another instance, then:
private static void Main(string[] args) { bool createdNew = true; using (Mutex mutex = new Mutex(true, "IPADcommunicator", out createdNew)) { if (createdNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } else { Process current = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcessesByName(current.ProcessName)) { if (process.Id != current.Id) { IntPtr handle = FindWindow(null,"IPADcommunicator"); SetForegroundWindow(handle); ShowWindow(handle,5); break; } } ...
Be that as it may, it does not work properly. The main window is not restored. I googled a lot and did not find solutions to this problem. Thanks in advance!
source share