zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    busybox 注意事项
    Implicit vs Explicit Sharing
    Font Creator Program 字库修改合并软件
    Iperf 源代码分析(四)
    QML 中文支持
    file operation
    MFC异常 与C++标准异常
    统一建模语言(UML) 版本 2.0
    MultiByteToWideChar和WideCharToMultiByte用法详解
    UML 基础: 类图
  • 原文地址:https://www.cnblogs.com/kongbursi-2292702937/p/15009379.html
Copyright © 2011-2022 走看看