OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/widget/widget_hwnd_utils.h" | 5 #include "ui/views/widget/widget_hwnd_utils.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 // Set type-dependent style attributes. | 74 // Set type-dependent style attributes. |
75 switch (params.type) { | 75 switch (params.type) { |
76 case Widget::InitParams::TYPE_PANEL: | 76 case Widget::InitParams::TYPE_PANEL: |
77 *ex_style |= WS_EX_TOPMOST; | 77 *ex_style |= WS_EX_TOPMOST; |
78 if (params.remove_standard_frame) { | 78 if (params.remove_standard_frame) { |
79 *style |= WS_POPUP; | 79 *style |= WS_POPUP; |
80 break; | 80 break; |
81 } | 81 } |
82 // Else, no break. Fall through to TYPE_WINDOW. | 82 // Else, no break. Fall through to TYPE_WINDOW. |
83 case Widget::InitParams::TYPE_WINDOW: { | 83 case Widget::InitParams::TYPE_WINDOW: { |
84 *style |= WS_SYSMENU | WS_CAPTION; | 84 // WS_OVERLAPPEDWINDOW is equivalent to: |
85 bool can_resize = widget_delegate->CanResize(); | 85 // WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | |
86 bool can_maximize = widget_delegate->CanMaximize(); | 86 // WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
87 if (can_maximize) { | 87 *style |= WS_OVERLAPPEDWINDOW; |
88 *style |= WS_OVERLAPPEDWINDOW; | 88 if (!widget_delegate->CanMaximize()) |
89 } else if (can_resize || params.remove_standard_frame) { | 89 *style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX); |
sky
2014/09/18 14:27:09
Why remove the minimize button if the window can't
jackhou1
2014/09/18 23:28:35
Hah, I was hoping you would know. There's this bug
| |
90 *style |= WS_OVERLAPPED | WS_THICKFRAME; | 90 if (!widget_delegate->CanResize()) |
91 } | 91 *style &= ~(WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX); |
92 if (params.remove_standard_frame) | |
93 *style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX); | |
94 | |
92 if (native_widget_delegate->IsDialogBox()) { | 95 if (native_widget_delegate->IsDialogBox()) { |
93 *style |= DS_MODALFRAME; | 96 *style |= DS_MODALFRAME; |
94 // NOTE: Turning this off means we lose the close button, which is bad. | 97 // NOTE: Turning this off means we lose the close button, which is bad. |
95 // Turning it on though means the user can maximize or size the window | 98 // Turning it on though means the user can maximize or size the window |
96 // from the system menu, which is worse. We may need to provide our own | 99 // from the system menu, which is worse. We may need to provide our own |
97 // menu to get the close button to appear properly. | 100 // menu to get the close button to appear properly. |
98 // style &= ~WS_SYSMENU; | 101 // style &= ~WS_SYSMENU; |
99 | 102 |
100 // Set the WS_POPUP style for modal dialogs. This ensures that the owner | 103 // Set the WS_POPUP style for modal dialogs. This ensures that the owner |
101 // window is activated on destruction. This style should not be set for | 104 // window is activated on destruction. This style should not be set for |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 DWORD class_style = 0; | 156 DWORD class_style = 0; |
154 CalculateWindowStylesFromInitParams(params, widget_delegate, | 157 CalculateWindowStylesFromInitParams(params, widget_delegate, |
155 native_widget_delegate, &style, &ex_style, | 158 native_widget_delegate, &style, &ex_style, |
156 &class_style); | 159 &class_style); |
157 handler->set_initial_class_style(class_style); | 160 handler->set_initial_class_style(class_style); |
158 handler->set_window_style(handler->window_style() | style); | 161 handler->set_window_style(handler->window_style() | style); |
159 handler->set_window_ex_style(handler->window_ex_style() | ex_style); | 162 handler->set_window_ex_style(handler->window_ex_style() | ex_style); |
160 } | 163 } |
161 | 164 |
162 } // namespace views | 165 } // namespace views |
OLD | NEW |