如何区分WS_POPUP、WS_OVERLAPPED和WS_CHILD

转载gwzz1228 最后发布于2012-07-25 11:58:47 阅读数 13625  收藏

展开

除了窗口类以外,还有成百上千种窗口风格供用户指定窗口的绘制及其行为。其中有 3种最重要的风格创建了对应3种最基本的窗口类型:重叠窗口、弹出窗口和子窗口。
■ 重叠窗口(overlapped window),具有应用程序主窗口的全部特点。它的非客户区包括一个可伸缩的框架、菜单条、标题栏和最小化、最大化按钮。
■ 弹出窗口(popup window),具有消息框或者对话框的全部特点。它的非客户区包括一个固定大小的框架和一个标题栏。

■ 子窗口(child window),具有类似按钮控件的全部特点。它没有非客户区,窗口的处理过程负责绘制窗口的每个部分。

///

WS_POPUP WS_OVERLAPPED WS_CHILD

  Overlapped Windows

An overlapped window is a top-level window that has a title bar, border, and client area; it is meant to serve as an application's main window. It can also have a window menu, minimize and maximize buttons, and scroll bars. An overlapped window used as a main window typically includes all of these components.

  By specifying the WS_OVERLAPPED or WS_OVERLAPPEDWINDOW style in the CreateWindowEx function, an application creates an overlapped window. If you use the WS_OVERLAPPED style, the window has a title bar and border. If you use the WS_OVERLAPPEDWINDOW style, the window has a title bar, sizing border, window menu, and minimize and maximize buttons.

Pop-up Windows

  Pop-up windows are top-level windows and are connected to the desktop window's child windows list. Applications usually use pop-up windows for dialog boxes. The main difference between pop-up and overlapped windows is that pop-up windows need not have captions and overlapped windows must have captions. When a pop-up window does not have a caption, it can be created without a border. Pop-up windows may own other top-level windows or be owned by other top-level windows or both. All pop-up windows have the WS_CLIPSIBLINGS style, even if it was not specified. Pop-up windows must not be created with the CW_USEDEFAULT value for either the position or the size of the window. Pop-up windows that use CW_USEDEFAULT will exist but will have no size or no position or both. Overlapped windows are usually reserved for your application's main window and, in fact, are sometimes called Main windows or Frame windows. Pop-up windows are usually used to communicate with the user in the form of Dialog boxes and Message boxes.

  A pop-up window is a special type of overlapped window used for dialog boxes, message boxes, and other temporary windows that appear outside an application's main window. Title bars are optional for pop-up windows; otherwise, pop-up windows are the same as overlapped windows of the WS_OVERLAPPED style.

  You create a pop-up window by specifying the WS_POPUP style in CreateWindowEx. To include a title bar, specify the WS_CAPTION style. Use the WS_POPUPWINDOW style to create a pop-up window that has a border and a window menu. The WS_CAPTION style must be combined with the WS_POPUPWINDOW style to make the window menu visible.

  Child Windows

Child windows must have a parent window and are confined to the client area of their parent. This is the major distinction between child windows and overlapped and pop-up windows. Child window parents can be top-level windows or other child windows. Child windows are positioned from their parent window's upper-left corner and not from the upper-left of the screen as are top-level windows. Child windows are clipped to the client area of their parent. Controls in a dialog box are child windows whose parent is the dialog box. Child windows must not be created with the CW_USEDEFAULT value for either the position or size of the window. Child windows that use CW_USEDEFAULT will exist but will have no size or position or both.

  A child window has the WS_CHILD style and is confined to the client area of its parent window. An application typically uses child windows to divide the client area of a parent window into functional areas. You create a child window by specifying the WS_CHILD style in the CreateWindowEx function.

  A child window must have a parent window. The parent window can be an overlapped window, a pop-up window, or even another child window. You specify the parent window when you call CreateWindowEx. If you specify the WS_CHILD style in CreateWindowEx but do not specify a parent window, the system does not create the window.

  A child window has a client area but no other features, unless they are explicitly requested. An application can request a title bar, a window menu, minimize and maximize buttons, a border, and scroll bars for a child window, but a child window cannot have a menu. If the application specifies a menu handle, either when it registers the child's window class or creates the child window, the menu handle is ignored. If no border style is specified, the system creates a borderless window. An application can use borderless child windows to divide a parent window's client area while keeping the divisions invisible to the user.

下面是谷歌翻译,哈哈。。。

/ / /
WS_POPUP WS_OVERLAPPED WS_CHILD
  重叠的窗口
  一个重叠窗口是顶层窗口有一个标题栏,边框和客户区,它的目的是作为一个应用程序的主窗口。 它也可以有一个窗口菜单,最小化和最大化按钮和滚动条。 重叠的窗口作为主窗口使用通常包括所有这些组件。
  通过CreateWindowEx函数中指定的WS_OVERLAPPED或WS_OVERLAPPEDWINDOW风格,一种应用程序创建一个重叠的窗口。 如果您使用WS_OVERLAPPED风格,窗口有一个标题栏和边框。 如果您使用WS_OVERLAPPEDWINDOW风格,窗口有一个标题栏,边框大小,窗口菜单,最小化和最大化按钮。
  弹出窗口
  弹出窗口是顶级窗口,并连接到桌面窗口的子窗口的列表。 应用程序通常使用对话框弹出窗口。 主要的区别弹出和重叠的窗口是弹出式窗口不需要有标题和重叠的窗口必须有标题。 当一个弹出窗口没有标题,它可以创建无边框。 弹出式窗口可能拥有其他顶级窗口或由其他顶级窗口或两者拥有。 所有弹出窗口都具有WS_CLIPSIBLINGS风格,即使是没有指定。 弹出窗口不能创建与CW_USEDEFAULT值无论是位置或窗口的大小。 弹出窗口,使用CW_USEDEFAULT会存在,但不会有任何大小或没有能力或两者兼而有之。 重叠的窗口通常是保留给应用程序的主窗口,而事实上,有时也被称为主窗口或框架窗口。 弹出窗口通常用于与用户在对话框的形式和消息框。
  一个弹出窗口是一个特殊类型的重叠窗口的对话框,消息框使用,以及其他外部的应用程序的主窗口中出现的临时窗口。 标题栏的弹出式窗口选择,否则,弹出窗口作为窗口重叠的WS_OVERLAPPED风格相同。
您创建一个通过指定CreateWindowEx WS_POPUP风格的弹出窗口。 要包含一个标题栏,指定WS_CAPTION样式。 使用WS_POPUPWINDOW风格创建一个弹出窗口,具有边框和窗口菜单。 该WS_CAPTION样式必须结合WS_POPUPWINDOW风格使窗口菜单中可见。
  子窗口
  子窗口必须有一个父窗口,并只限于其母公司的客户区。 这是在子窗口和重叠和弹出窗口的主要区别。 子窗口家长可以顶层窗口或其他子窗口。 子窗口的位置,从他们的父窗口的左上角,而不是从上层作为屏幕的左侧是顶层窗口。 子窗口是夹在他们父母的客户区。 在一个对话框中的控件的子窗口,其母公司是对话框。 子窗口创建不能为任何位置或窗口的大小CW_USEDEFAULT值。 子窗口,使用CW_USEDEFAULT会存在,但不会有任何大小或位置或两者兼而有之。
  有一个子窗口WS_CHILD样式,并只限于它的父窗口的客户区。 应用程序通常使用子窗口功能区划分成一个父窗口客户区。 您创建一个通过指定CreateWindowEx函数WS_CHILD样式的子窗口。
  一个子窗口必须有一个父窗口。 父窗口可以是重叠的窗口,弹出一个窗口,甚至是另一个子窗口。 您指定的父窗口时调用CreateWindowEx。 如果您指定在CreateWindowEx WS_CHILD样式,但没有指定一个父窗口,系统不创建窗口。
  一个孩子,但没有一个窗口客户区的其他功能,除非他们明确要求。 应用程序可以请求一个标题栏,窗口菜单,最小化和最大化按钮,边框,滚动窗花一个孩子,但一个子窗口不能有菜单。 如果应用程序指定一个菜单句柄,或者当它注册孩子的窗口类或创建子窗口,菜单句柄将被忽略。 如果没有指定边框样式,系统将创建一个无边框窗口。 应用程序可以使用无国界划分一个子窗口的父窗口的客户区的划分,同时保持对用户不可见。

【转载】http://www.cnblogs.com/ziwuge/archive/2010/12/27/1917817.html

如何区分WS_POPUP、WS_OVERLAPPED和WS_CHILD相关推荐

  1. Windows窗口分析

    (本文尝试通过一些简单的实验,来分析Windows的窗口机制,并对微软的设计理由进行一定的猜测,需要读者具备C++.Windows编程及MFC经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...

  2. windows窗口分析,父窗口,子窗口,所有者窗口

    (本文尝试通过一些简单的实验,来分析Windows的窗口机制,并对微软的设计理由进行一定的猜测,需要读者具备C++.Windows编程及MFC经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...

  3. 转载:Windows CE内存管理

    内存管理 如果你在写Windows CE 程序中遇到的最重要的问题,那一定是内存问题.一个WinCE 系统可能只有4MB 的RAM,这相对于个人电脑来说是十分少的,因为个人电脑的标准配置已经到了128 ...

  4. MFC——CWnd类

    整理一下自己对于CWnd类的笔记. CWnd类的子类分为四种:Frame(框架).Dialog(对话框).View(视图).Control(控件) 函数 1.virtual BOOL Create(L ...

  5. Windows API 常量定义

    Windows 常量定义在winuser.h中可以找到,如果了安装了visual studio 2010,winuser.h所在目录为C:\Program Files (x86)\Microsoft ...

  6. 吕鑫MFC学习系列六

    这一章学习的相关知识框架: 一.根据主窗口类型,MFC软件工程可以分为以下几种架构模型: 1.SDI(Single Document Interface):单文档界面,一个主框架窗口下只能编辑一份文档 ...

  7. Windows窗口相关的一些概念解释

    原文出处:http://blog.sina.com.cn/s/blog_48f93b530100eamd.html 最近工作中关于UI开发方面的东西多了些,碰到问题的时候查阅了很多资料,对Window ...

  8. 顶级(top-level window)窗口,被拥有窗口(owned window),子窗口(child window) 与WS_POPUP,WS_CHILD深入浅出

    CreateWindow 在介绍众多概念前先看一下创建窗口的函数,如下所示: 当创建该窗口的hWndParent为有效的窗口句柄时,代表他被拥有了,这里我很想吐槽微软,为什么名字起的让人感觉他们可能是 ...

  9. Qt pro文件下跨平台宏的使用(windows/linux 以及x86 和 arm的区分)

    #Qt pro文件下跨平台宏的使用(windows/linux 以及x86 和 arm的区分) 在pro文件中添加: #仅在linux 系统下, 硬件平台无关的内容 unix{HEADERS += \ ...

最新文章

  1. php 缓存模块,PHP缓存之模块缓存(APC)_PHP教程
  2. (五)Docker镜像管理1之镜像操作
  3. 研究javascript中的this
  4. 多种特征提取算法比较汇总
  5. 由 Session 和 Cookie 的区别说起
  6. Android开发之recyclerview布局加载不全的问题
  7. 『ACM--算法--KMP』信息竞赛进阶指南--KMP算法(模板)
  8. nginx重启命令方法(linux,centos,ubuntu)总结
  9. 证书 vivo_vivo秦飞:真假5G不存在 NSA模式手机未来仍可用
  10. H3C交换机做DHCP
  11. VisualSVN 破解方法
  12. 新历(公历、西历)转换农历(精确…
  13. 美团App页面视图可测性改造实践
  14. esclip直接快捷键构造函数_IntelliJ Idea 常用快捷键
  15. 计算机老是卡顿怎么解决,电脑反应太慢怎么处理_电脑卡顿什么原因-win7之家
  16. ubuntu 安装ATI驱动
  17. 总结一下:运维工程师面试的经历及面试相关问题
  18. 查找读者姓名mysql_练习1.sql · 刘友亮/mysql第三次作业 - Gitee.com
  19. 第12期《 蓄势待发 》1月刊
  20. 如何提高节点下线速度或避免因节点掉线产生网络风暴?

热门文章

  1. TypeScript-Int64实现
  2. Uniprot数据库
  3. Web开发-Lodop打印控件实践
  4. 远程连接模拟真机ADB 调试工具安装详解
  5. C++实现99乘法表
  6. 反手来个K8S入门到跑路
  7. 智能家居未来已来,可没做到这点便是“鸡肋”!
  8. AXI smartconnect
  9. 【Hadoop离线基础总结】MapReduce增强(上)
  10. #652 (Div. 2)C. RationalLee(贪心)