如何区分WS_POPUP、WS_OVERLAPPED和WS_CHILD

除了窗口类以外,还有成百上千种窗口风格供用户指定窗口的绘制及其行为。其中有 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

你可能感兴趣的:(windows,application,dialog,border,scroll,menu)