阅读 93

SetForegroundWindow与BringWindowToTop函数的作用

一、BringWindowToTop

首先介绍两个概念

1、什么是顶级窗口

顶级窗口通常是一个没有父窗体或者父窗体是桌面的窗口,通常也把应用程序的主窗体叫做“顶级窗口”(注意和置顶窗口区别)

顶级和置顶不是一码事,窗口的Z序或者topmost都是窗体样式的设置,顶级窗体应该就是父窗体句柄为0的窗体,也可以说是父窗体。

举个例子,如果说在所有窗体前面就算是顶级窗体,那谁能给我解释一下,任务管理器是topmost状态时,他的新建任务的打开窗口难道也是顶级了?

下面这一小段英文来自MSDN
A top-level form is a window that has no parent form, or whose parent form is the desktop window. Top-level windows are typically used as the main form in an application.

我翻译给上面某些错误理解顶级窗口的朋友们看看:

顶级窗口通常是一个没有父窗体或者父窗体是桌面的窗口,通常也把应用程序的主窗体叫做“顶级窗口”

 

2、Z顺序

我理解:窗体可以层叠,从底层往上层数,有个顺序的,那个就是Z序

 

bringwindowtotop :如果窗口为顶层窗口,则该窗口被激活;如果窗口为子窗口,则相应的顶级

The BringWindowToTop function brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.

译文:bringwindowtop函数将指定的窗口置于Z顺序的顶部。如果该窗口是顶级窗口,则它将被激活。如果窗口是子窗口,则激活与子窗口关联的顶级父窗口。

 

二、SetForegroundWindow 

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, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.

 

原文:https://www.cnblogs.com/kongbursi-2292702937/p/15009379.html

文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐