GetActiveWindow与GetForegroundWindow两者有何区别?

来自MSDN:
  The active window is either the window that has the current input focus or the window explicitly made active by the SetActiveWindow member function 
  The foreground window applies only to top-level windows(frame windows or dialog boxes).
   
   网上有人说:
GetActiveWindow() 是你的程序的当前激活的窗口。

GetForegroundWindow() 是整个Windows系统的当前激活的窗口。


GetActiveWindow 只是获取当前程序中(严格地说是线程中)被激活的窗口;
GetForegroundWindow 是获取当前系统中被激活的窗口.

两个函数的级别不一样, 一个是线程级、一个是系统级.

被激活的窗口不一定是顶层窗口(最上面的窗口).

The SetActiveWindow function activates a window, but not if the application is in the background. The window will be brought into the foreground — the top of z-order — if the application is in the foreground when it sets the activation. 
    The SetForegroundWindow window function, on the other hand, activates a window and forces it into the foreground. An application should only call SetForegroundWindow if it needs to display critical errors or information that needs the user's immediate attention. 
    看了这个有点明白了,SetActiveWindow函数只有激活最前面的那个窗口(foreground  —— the top of z-order)才能使该窗口为当前窗口。而SetForegroundWindow强迫设置窗口为最前面的窗口并激活它使它成为当前窗口。SetForegroundWindow包含有SetActiveWindow的激活功能。


最前的窗口不一定是激活的...比如说qq的主窗口,只要不靠到屏幕边上,就是总在最前的,你拖放一个ie过去是挡不住的,这时候,你用GetActiveWindow得到的是有焦点的ie窗口,用GetForegroundWindow得到的是qq的窗口,不知道我的描述你能否理解,呵呵


  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值