【发布时间】:2011-01-04 10:59:26
【问题描述】:
好的,标题很长,应该能说明我面临的问题。
这是最小化到图标托盘时的代码:
void MainFormResize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
this.Hide();
this.ShowInTaskbar = false;
}
}
当程序已经打开并在系统托盘中,并且仍然有人想打开它的另一个实例时,那么:
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;
}
}
...
但是,它无法正常工作。主窗口未恢复。 我用谷歌搜索了很多,但没有找到解决该问题的方法。 提前致谢!
【问题讨论】: