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写的,可以把你写的主窗口置顶,置底(看样子应该可以变成桌面了,还没试呢,才忙到现在...) 子窗口的遮挡可以使用窗口的样 ...
随机推荐
- [jbdj]SpringMVC框架(1)快速入门
1)springmvc快速入门(传统版) 步一:创建springmvc_demo一个web应用 步二:导入springioc,springweb , springmvc相关的jar包 步三:在/WEB ...
- 平板点餐软件编程体会---记我的Android编程之路
前言 想开发一个平板点餐系统,研究下陈江根大侠分享的一个很高水准的实例,只是个单机版无实用意义. (如需运行源码请回复联系邮箱) 实现 Mysql 数据库+Tomcat WEb服务器,使用Servle ...
- Klass与Oop
前段时间,一直在看<Hotspot实战>,顺便编译了一份OpenJDK的源码,然后就在eclipse里面调试起来. 虽然我的入门语言是c/c++,但是被Java拉过来好几年了,现在再看源码 ...
- PHP超全局变量$_SERVER
$_SERVER 是一个包含了诸如头信息(header).路径(path).以及脚本位置(script locations)等等信息的数组.这个数组中的项目由 Web 服务器创建.不能保证每个服务器都 ...
- 安装 Docker Machine - 每天5分钟玩转 Docker 容器技术(45)
前面我们的实验环境中只有一个 docker host,所有的容器都是运行在这一个 host 上的.但在真正的环境中会有多个 host,容器在这些 host 中启动.运行.停止和销毁,相关容器会通过网络 ...
- net.sz.framework 框架 ORM 消消乐超过亿条数据排行榜分析 天王盖地虎
序言 天王盖地虎, 老婆马上生孩子了,在家待产,老婆喜欢玩消消乐类似的休闲游戏,闲置状态,无聊的分析一下消消乐游戏的一些技术问题: 由于我主要是服务器研发,客户端属于半吊子,所以就分析一下消消乐排行榜 ...
- css实现鼠标悬浮字体流光背景模糊效果
原文地址:→看过来 写在前面 有的时候感觉写点小玩意儿挺开心的,还能实践很多的小知识点,所以这次学着写了个有趣的鼠标悬浮模糊效果,只使用了css额. 效果图 源码地址→传送门 预览地址→传送门 小知识 ...
- Objective-C 自定义UISlider滑杆 分段样式
效果 自定义一个功能简单的分段的滑杆 可显示分段名 为了显示效果,我们将滑块和节点都设置为不规则 这里只实现了分段的slider,未分段的没有实现,有兴趣的可以定义另一种类型做个判断修改下 需求分析 ...
- angular JS中使用jquery datatable 自定义搜索按钮点击事件 和mRender的 ng-click事件
'use strict'; app.controller('DataTableCtrl', function ($scope, $compile) { $scope.searchFiles = { n ...
- ueditor编辑器使用总结
ueditor使用小结 一.简介 ueditor是百度编辑器,官网地址:http://ueditor.baidu.com/website/ 完整的功能演示,可以参考:http://ueditor.ba ...