前景与活动窗口 [英] Foreground Vs Active window

查看:44
本文介绍了前景与活动窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 中,前台窗口和活动窗口有什么区别?具体来说,在什么情况下前台窗口不能是活动窗口?如果这 2 个术语指的是同一个概念,为什么会有 2 个术语.

In Windows, what is the difference between foreground and active window? To be specific, under what circumstances can a foreground window not be an active window? If the 2 terms are referring to the same concept why there're 2 terms.

此处的 msdn 文档提到单击窗口,或使用 ALT+TABALT+ESC 组合键"使窗口和前景都处于活动状态.这两个术语之间没有明确的区别.检查 MSDN.

The msdn documentation here mentions "clicking a window, or by using the ALT+TAB or ALT+ESC key combination" makes a window active as well as foreground. There is nothing explicitly about the difference between the 2 terms.Check MSDN.

推荐答案

活动窗口(GetActiveWindow() 的结果)是附加到调用线程的窗口得到输入.前景窗口(GetForegroundWindow() 的结果)是当前正在获取输入的窗口,而不管它与调用线程的关系如何.活动窗口本质上是针对您的应用程序本地化的;前台窗口对系统来说是全局的.

The active window (the result of GetActiveWindow()) is the window attached to the calling thread that gets input. The foreground window (the result of of GetForegroundWindow()) is the window that's currently getting input regardless of its relationship to the calling thread. The active window is essentially localized to your application; the foreground window is global to the system.

例如,如果属于另一个进程的窗口是前台,则从您自己的进程中调用 GetActiveWindow() 将返回 NULL.

For example, if a window belonging to another process is the foreground, calling GetActiveWindow() from within your own process will return NULL.

我相信作为前景窗口意味着是活动窗口是正确的,但反之则不然.另请注意,在现代 Windows 中,应用程序通常无法使用 SetForegroundWindow() 从另一个进程窃取焦点(除非该进程已通过 AllowSetForegroundWindow 明确授予权限).

I believe that it's true that being the foreground window implies being the active window, but the converse is not true. Also note that in modern Windows, applications generally cannot use SetForegroundWindow() to steal focus from another process (unless that process has explicitly given permission via AllowSetForegroundWindow).

这篇关于前景与活动窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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