好吧,标题很长,应该告诉我面临的问题.
这是最小化图标托盘时的代码:
void MainFormResize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
this.Hide();
this.ShowInTaskbar = false;
}
}
Run Code Online (Sandbox Code Playgroud)
当程序已经打开并且在sys托盘中时,仍然有人想要打开它的另一个实例,那么:
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;
}
}
...
Run Code Online (Sandbox Code Playgroud)
但是,它不能正常工作.主窗口没有恢复.我已经google了很多,并没有找到解决这个问题的方法.提前致谢!
| 归档时间: |
|
| 查看次数: |
4554 次 |
| 最近记录: |