一、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.