Click here to Skip to main content
Rate this: bad
good
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 1:53am
gwithey788
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Try hiding the main window of the App1.
VB.
suppose app1's main form is form1
Form1.Hide()
C#
suppose app1's main form is form1
Form1.Hide();
  Permalink  
Comments
Jegan Thiyagesan at 18-Feb-13 7:21am
   
Assuming Application 1 and 2 are separate process, your solution will not work.
 
Jegan
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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:
 
    //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
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2014
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