只让程序运行一次,激活还原前面打开的窗体
只让程序运行一次,激活还原前面打开的窗体,我是这样 写的
public static void HandleRunningInstance(Process instance)
{
if (instance.MainWindowHandle.ToInt32() != 0)
{
ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL);
SetForegroundWindow(instance.MainWindowHandle);
}
else
{
IntPtr hwnd = FindWindow(null, " XX");
if (hwnd.ToInt32() == 0)
hwnd = FindWindow(null, " XX");
ShowWindowAsync(hwnd, WS_SHOWNORMAL);
SetForegroundWindow(hwnd);
ShowWindow(hwnd, 9);
}
}
我最小化到托盘之后在运行程序 ,可以激活还原,但是在屏幕的左下角出现了一个 长方形的 框,就是最小化 过去的,请问这个如何解决。