如何在第二个实例运行时将我的应用程序带到前台 [英] How to bring My application to foreground when second instance running

查看:67
本文介绍了如何在第二个实例运行时将我的应用程序带到前台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个窗口应用程序,在运行我的应用程序的第二个实例时,我想将现有的UI显示为前台。



我用过以下代码:



public static void ShowToFront(IntPtr window)

{



ShowWindowAsync(window,SW_SHOWNORMAL);

SetForegroundWindow(窗口);



}



此外,



protected override void WndProc(ref message message)

{

if(message.Msg == WM_SHOWFIRSTINSTANCE)

{

ShowToFront(this.Handle);

}

base.WndProc(参考留言);

}



使用以上代码,我无法将我的UI带到前面。它在任务栏上闪烁。



请帮帮我。



在此先感谢.. 。

Hi All,

I have an window application, when running second instance of my application I want to show the existing UI to foreground.

I have used the below code:

public static void ShowToFront(IntPtr window)
{

ShowWindowAsync(window, SW_SHOWNORMAL);
SetForegroundWindow(window);

}

Also,

protected override void WndProc(ref Message message)
{
if (message.Msg == WM_SHOWFIRSTINSTANCE)
{
ShowToFront(this.Handle);
}
base.WndProc(ref message);
}

Using the above code, I was not able to bring my UI to front. It was blinking on the taskbar.

Please help me on this.

Thanks in advance...

推荐答案

这里是 [ ^ ]一个解决方案,即依赖于众所周知的窗口标题的存在。



/ ravi
Here's[^] one solution, that relies on the existence of a well-known window caption.

/ravi


这篇关于如何在第二个实例运行时将我的应用程序带到前台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆