1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/win/hwnd_util.h"
7 #include "ui/views/widget/widget.h"
11 HWND HWNDForView(const View* view) {
12 return view->GetWidget() ? HWNDForWidget(view->GetWidget()) : NULL;
15 // Returns the HWND associated with the specified widget.
16 HWND HWNDForWidget(const Widget* widget) {
17 return widget->GetNativeView();
20 HWND HWNDForNativeView(const gfx::NativeView view) {
24 HWND HWNDForNativeWindow(const gfx::NativeWindow window) {
28 gfx::Rect GetWindowBoundsForClientBounds(View* view,
29 const gfx::Rect& client_bounds) {
31 HWND hwnd = view->GetWidget()->GetNativeWindow();
32 RECT rect = client_bounds.ToRECT();
33 DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
34 DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
35 AdjustWindowRectEx(&rect, style, FALSE, ex_style);
36 return gfx::Rect(rect);