简体   繁体   English

2应用程序Top问题最多

[英]2 Application Top Most problem

I developed 2 applications one in Win32 API and second in C# WPF. 我在Win32 API中开发了两个应用程序,在C#WPF中开发了第二个应用程序。 I have a problem, 2 applications must be top most, but second (in C#) must be stroger top most than first application, problem is second application is run from autostart then will be always faster launched than first application, and first application is more top most than second? 我有一个问题,2个应用程序必须是最顶层的,但第二个(在C#中)必须比第一个应用程序更强大,问题是第二个应用程序从自动启动运行然后将始终比第一个应用程序更快启动,并且第一个应用程序更多最高于第二?

How i can do second application more top most? 我怎样才能做到第二次申请最多? Or how i can show second application on topmost when already have top most and this is under first application? 或者,如果我已经拥有最顶级的第二个应用程序,那么我是如何在第一个应用程序中显示的

Can anyone help me? 谁能帮我? Greetings, 问候,

From http://msdn.microsoft.com/en-us/library/system.windows.window.topmost.aspx : 来自http://msdn.microsoft.com/en-us/library/system.windows.window.topmost.aspx

In the group of windows that have Topmost property is set to true, the window that is currently activated is the topmost window. 在将Topmost属性设置为true的窗口组中,当前激活的窗口是最顶层的窗口。

So activate the window that you want to be the top-top-topmost :-) ... 所以激活你想要成为顶尖顶部的窗口:-) ...

EDIT: I agree with Pieter that doing this is something that is almost always a bad idea (taking control from the user). 编辑:我同意彼得的观点,这样做几乎总是一个坏主意(从用户那里获得控制权)。 This is why MS does not go out of its way to give you tools to do stuff like you want to do. 这就是为什么MS不会为你提供工具去做你想做的事情。 I'll give you the benefit of the doubt and not tell you "do not do this" 我会给你怀疑的好处,而不是告诉你“不要这样做”

This is not something you should want to do. 这不是你想要做的事情。

Whether one application or the other is on top, is something you want to leave to the user. 无论是一个应用程序还是另一个应用程序都是最重要的,您希望留给用户。

However, there are options. 但是,有选择。

Using FindWindow , you can find the window handle of the window that was started first. 使用FindWindow ,您可以找到首先启动的窗口的窗口句柄。 Then, when you have this handle, you can use SetWindowPos to ensure that your window is on top of the other window you've found. 然后,当您拥有此句柄时,可以使用SetWindowPos确保您的窗口位于您找到的另一个窗口的顶部。 You use the z-ordering arguments of SetWindowPos to achieve this. 您可以使用SetWindowPos的z-ordering参数来实现此目的。

Note: these are both PInvoke methods. 注意:这些都是PInvoke方法。 Use the PInvoke for FindWindow and SetWindowPos to call these methods from C#. 使用PInvoke for FindWindowSetWindowPos从C#调用这些方法。

I see only one way. 我只看到一种方式。 Second app should monitor first untill first app lunched. 第二个应用程序应首先监控第一个应用程序。 After that, you should remove top most style from second app and take it back. 之后,您应该从第二个应用程序中删除最顶级的样式并将其取回。 This action brings second app top most. 此操作带来第二个应用程序最顶层。 It's not elegant but it works 它不优雅,但它的工作原理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM