Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...
Posted
Comments
BillWoodruff 23-Sep-14 11:05am    
"show the existing UI" : I find this confusing: doesn't each instance of your application have its own UI ?

What event in one instance triggers the bringing to the front of the other instance you want ?
Philippe Mori 23-Sep-14 20:32pm    
Use code block for you code!

1 solution

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

/ravi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900