Click here to Skip to main content
13,195,379 members (66,874 online)
Rate this:
Please Sign up or sign in to vote.
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 18-Feb-13 0:53am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try hiding the main window of the App1.
suppose app1's main form is form1

suppose app1's main form is form1
Jegan Thiyagesan 18-Feb-13 7:21am
Assuming Application 1 and 2 are separate process, your solution will not work.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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:

    //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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171019.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100