如何在应用程序中只将一个窗口带到前面。 [英] How to bring only 1 window within an application to the front.

查看:53
本文介绍了如何在应用程序中只将一个窗口带到前面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有点陷入窗口分层问题。



我有一个应用程序(App1)应该将另​​一个应用程序(App2)带到前面似乎工作正常,但原始应用程序(App1)应该将其中一个窗口(不是整个应用程序)带到另一个应用程序的前面( App2)。



我到这里的问题是,当我点击当前位于顶部的小对话框(App1)时,它会将整个(App1)带到前隐藏(App2)。



有没有人知道如何阻止(App1)中的小对话框将整个应用程序带到前面并让自己成为最顶层的。



先谢谢George

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

推荐答案



尝试隐藏App1的主窗口。

VB。

假设app1的主要形式是form1

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



C#

假设app1的主要表格是form1


C#
suppose app1''s main form is form1

Form1.Hide();


您好,

当您点击第一个应用程序(App1)中的对话框时,您正在激活此应用程序因此第二个应用程序将失去它的状态。



第一个选项:

将对话框放在你面前的一种方法第二个应用程序是从第二个应用程序调用对话框。



第二个选项:

从您的第一个应用程序调用您的第二个应用程序并获取处理程序ID。

在第一个应用程序中以Modal打开对话框,即ShowDialog()。

然后调用user32.dll以使用其处理程序ID引入第二个应用程序,如下所示:



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);
}





我希望这会有所帮助。



问候

Jegan



I hope this helps.

Regards
Jegan


这篇关于如何在应用程序中只将一个窗口带到前面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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