除了窗口類以外,還有成百上千種窗口風格供用戶指定窗口的繪制及其行為。其中有 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樣式,但沒有指定一個父窗口,系統不創建窗口。
一個孩子,但沒有一個窗口客戶區的其他功能,除非他們明確要求。 應用程序可以請求一個標題欄,窗口菜單,最小化和最大化按鈕,邊框,滾動窗花一個孩子,但一個子窗口不能有菜單。 如果應用程序指定一個菜單句柄,或者當它注冊孩子的窗口類或創建子窗口,菜單句柄將被忽略。 如果沒有指定邊框樣式,系統將創建一個無邊框窗口。 應用程序可以使用無國界劃分一個子窗口的父窗口的客戶區的劃分,同時保持對用戶不可見。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
