API将窗口置于前端

API将窗口置于前端

本文介绍了使用Win32 API将窗口置于前端,在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写,需要把外部应用程序的窗口到前台应用程序,而不一定是窃取焦点(有一个设置用户可以切换偷/不偷焦点)。

I am writing an application that needs to bring window of an external app to the foreground, and not necessarily steal focus (there is a setting the user can toggle to steal/not steal focus).

什么是去这使用Win32 API的最好方法?我曾尝试SetForeground(),但它总是偷重点,不consistenly工作。

What is the best way to go about this using the win32 API? I have tried SetForeground() but it always steals focus and does not consistenly work.

什么是去最好的方法?有什么想法?

What is the best way to go about this? Any thoughts?

推荐答案

SetForegroundWindow应该窃取焦点,并有一定的情况下,它会失败。

SetForegroundWindow is supposed to steal focus and there are certain cases where it will fail.

该SetForegroundWindow函数将创建指定的窗口到前台线程并激活窗口。键盘输入被引导到窗口

The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window

尝试使调用之前捕捉与的焦点。还应考虑把窗口前不同的方式:SetForeGroundWindow,SetActiveWindow,甚至模拟鼠标点击可以做到这一点。

Try capturing the focus with SetCapture prior to making the call. Also look into different ways of bringing the window to the front: SetForeGroundWindow, SetActiveWindow, even simulating a mouse click can do this.

这篇关于使用Win32 API将窗口置于前端,在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 09:38