Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am a little stuck with a window layering issue.

I have an application (App1) which should bring another application (App2) to the front which seems to work ok, yet the original application (App1) should bring one of its windows (Not the whole app) to the front of the other application (App2).

The issue i am getting here is when i click the small dialog which is currently on top (App1) it brings the whole of (App1) to the front hiding (App2).

Does anyone know how to stop the small dialog in (App1) from bringing its whole application to the front and allowing just itself to be topmost.

Thanks in Advance George
Posted

Hi,
Try hiding the main window of the App1.
VB.
suppose app1's main form is form1
VB
Form1.Hide()

C#
suppose app1's main form is form1
C#
Form1.Hide();
 
Share this answer
 
Comments
Jegan Thiyagesan 18-Feb-13 7:21am    
Assuming Application 1 and 2 are separate process, your solution will not work.

Jegan
Hi,
When you click on the dialog in your first app(App1) you are activating this app and therefor the second app will loose it's status.

First Option:
One way to bring your dialog in front of your second app is to call the dialog from the second app.

Second Option:
Call your second app from your first app and get the handler ID.
Open your dialog in the first app as Modal i.e. ShowDialog().
then call the user32.dll to bring in the second app using its handler id as below:

C#
//Import the SetForeground API to activate it
[DllImport("User32.dll", EntryPoint = "SetForegroundWindow")]
private static extern IntPtr SetForegroundWindowNative(IntPtr hWnd);

public IntPtr SetForegroundWindow(IntPtr hWnd)
{
    return SetForegroundWindowNative(hWnd);
}


I hope this helps.

Regards
Jegan
 
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