SetWindowPos和SetForegroundWindow
There are many closely-related concepts involved, and related terms are often misused, even in the official documentation.
Important types of windows:
top-level windows: Windows that have no parent window. The main window for an application is almost always a top-level window. It does not have anything to do with z-order.
child windows: Windows that are contained by a parent window. Their position is always relative to the parent widow's area. Child windows are often "controls": UI things like buttons and edit boxes.
parent windows: Windows that have child windows. Top-level windows often have children. But note that child windows may also have children and thus be both parent and child windows.
owned windows: Windows that are controlled by a another window, but aren't necessarily children of the other window. An example is a floating tool palette: it's owned by another window in the application, but it's not locked to that other window's area.
owner windows: Windows that own an owned window.
Often the distinction between an owner/owned relationship and a parent/child relationship isn't important, so the parent and child terms are often used for both contexts, even in documentation. In some cases, parent fields and parameters are overloaded to mean parent and/or owner.
Important concepts:
top of the z-order: This literally means the window that displays above other windows.
active window: A fuzzy concept, but it typically means the top-level window the user would consider the "current" window. The active window is typically drawn with a distinctive border and its tile on the task bar is highlighted. The active window is usually at or near to the top of the z-order among all other top-level windows, and it is the parent or owner (perhaps indirectly) of the window with keyboard focus.
keyboard focus: Indicates the window that will receive the keyboard messages. Conceptually, there is one window with keyboard focus. Often the window with focus is a child (or grandchild, etc.) of the active window.
foreground: The active window is typically in the foreground. The name seems to suggest that it's at the top of the z-order, but it really means that the thread that created the window gets a slight priority boost. That active window is usually also the foreground window.
So let's say you've got this browser window open, and you've also got an instance of Notepad running. If you click on the document in Notepad, a whole flurry of messages and state changes occur. You're actually clicking on a big edit box, which is a child window of Notepad's top-level window. That click causes the edit box to get activated, but child windows can't really be the "active" window, so it just takes the keyboard focus and passes the activation message up through its ancestors until it gets to a top-level window. The top-level window "activates" by moving to the top of the z-order, highlighting its border, etc. It also becomes the foreground window, so its thread gets a little boost to make the UI a little more responsive than any other windows.
With these terms in mind, you can parse the MSDN descriptions for the functions you listed to tease out the subtle differences.
If you're trying to lay out your window's children, just use SetWindowPos (or MoveWindow, SizeWindow, and ShowWinow). Of the remaining functions, SwitchToThisWindow looks deprecated and essentially the same as SetForegroundWindow. (Note that, in many cases, SetForegroundWindow won't do what you want unless you're the active application or the active application has given you permission to use it.) BringWindowToTop is mostly about bringing a window to the top of the z-order (which you can do with SetWindowPos), with extra side effects that make it behave like SetForegroundWindow if you call it on a top-level window.
SetWindowPos和SetForegroundWindow的更多相关文章
- (C++)窗口置前SetForegroundWindow(pThis->hwndWindow);
一段代码主要是创建一个Window,然后将其置顶显示.奇怪的是这个功能有时候无效. pThis->bWindowDisplayed = SetForegroundWindow(pThis-> ...
- BringWindowToTop(), SetForegroundWindow(), SetActiveWindow()
1. SetActiveWindow() 原型: <span style="font-size:14px;">CWnd* SetActiveWindow(); HWND ...
- 将窗口置顶的方法:SetWindowPos、AttachThreadInput、SwitchToThisWindow
将窗口置顶的方法:SetWindowPos.AttachThreadInput.SwitchToThisWindow [转]http://hi.baidu.com/neil_danky/item/f9 ...
- SetWindowPos 和Z序
参考文档:http://www.cnblogs.com/findumars/p/3948315.html SetWindowPos(hWnd: HWND; {窗口句柄}hWndInsertAfter: ...
- AdjustWindowRect 与 SetWindowPos
这两个函数经常一起使用,所以放到一起讲: 1 AdjustWindowRect 函数功能:该函数依据所需客户矩形的大小,计算需要的窗口矩形的大小.计算出的窗口矩形随后可以传递给CreateWindow ...
- MFC 的SetWindowPos 用法
转自于:http://hi.baidu.com/max_new/blog/item/e2bbe607b1f127c57b8947c0.html 许多软件,特别是占桌面面积不是很大的软件,通常都提供了一 ...
- delphi API: SetWindowPos改变窗口的位置与状态
SetWindowPos 函数功能:该函数改变一个子窗口,弹出式窗口式顶层窗口的尺寸,位置和Z序.子窗口,弹出式窗口,及顶层窗口根据它们在屏幕上出现的顺序排序.顶层窗口设置的级别最高,并且被设置为Z序 ...
- SetForegroundWindow以及 如何将一个某个窗口提到最顶层(转)
http://hi.baidu.com/gookings/item/2b7912ca8d5b3625a0b50aa2 SetForegroundWindow 函数功能:该函数将创建指定窗口的线程设置到 ...
- SetWindowPos,RegisterHotKey,GlobalAddAtom的用法
还以为SetWindowPos是给Frm的子框架间编写的,原来是给mainfrm写的,可以把你写的主窗口置顶,置底(看样子应该可以变成桌面了,还没试呢,才忙到现在...) 子窗口的遮挡可以使用窗口的样 ...
随机推荐
- 使用pillow生成分享图片
重复性的工作一定要交给计算机去做! 有时候要为公司做一张宣传用的分享图片,很简单交给设计通过ps.AI做好就行了,但是如果一个网站要为每个用户生成一张专属的分享图片,如果让设计师一张一张的去做,哪设计 ...
- 【学习笔记】C# 构造和析构
构造方法 构造方法是一个特殊的方法,负责初始化对象 构造方法名必须和类名一致 构造方法没有返回值,但可以有参数,能够重载 构造方法可以不写,系统会自动为类添加一个无参的默认构造 如果将构造方法设置为P ...
- poj_3461: Oulipo
题目链接 基础KMP题,本文提供一段能AC并且便于调试以及查看next数组的代码. 参考博客 http://blog.csdn.net/v_july_v/article/details/7041827 ...
- Windows远程linux服务器执行shell命令
一.前言 借用百度百科关于putty的描述:PuTTY是一个Telnet.SSH.rlogin.纯TCP以及串行接口连接软件.较早的版本仅支持Windows平台,在最近的版本中开始支持各类Unix平台 ...
- 记录Centos一些坑
首先说一下写这篇博客的初衷. 最近去客户现场出差,搭建一套服务端的自动构建环境. 准备支持的环境有CentOS 7.5.java8.Tomcat 8.maven3.3.9.TBA 2.1.9.4 等等 ...
- WPF转换器之通用转换器
WPF中的转换器是一个非常好的数据类型转换解决方案,实用和强大, 它的作用是将源数据转换为WPF自身需要的类型,对数据实体没有侵略性,会在项目工程中频繁使用.所以掌握转换器是WPF开发的必备技能. 我 ...
- golang windows 安装方法
编译器下载链接:https://golang.org/dl/ 默认安装到C盘,不用修改. 添加环境变量: 配置环境变量: 注:C:\mygo\bin 配置这个后,则可以直接在 Dos ...
- 【D3】transition API
摘要: 动画类API 一.API 使用 1. 1 d3.ease 1.2 d3.timer Start a custom animation timer, invoking the specified ...
- springMVC 中几种获取request和response的方式
1.最简单方式:参数 例如: @RequestMapping("/test") @ResponseBody public void saveTest(HttpServletRequ ...
- c++STL(栈、队列)
栈stack -先入后出FILO 栈可以理解为一个坑,先掉坑里的被压在下面,等上面的走了才能出来 头文件 <stack> 入栈 push(某东西); 栈顶元素出栈 pop(); 是否为空 ...