summaryrefslogtreecommitdiffstats
path: root/ui/views/win/hwnd_util_win.cc
blob: abc05f8ec84fdc18535c84f99a54a09662126d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/win/hwnd_util.h"

#include "ui/views/widget/widget.h"

namespace views {

HWND HWNDForView(const View* view) {
  return view->GetWidget() ? HWNDForWidget(view->GetWidget()) : NULL;
}

// Returns the HWND associated with the specified widget.
HWND HWNDForWidget(const Widget* widget) {
  return widget->GetNativeView();
}

HWND HWNDForNativeView(const gfx::NativeView view) {
  return view;
}

HWND HWNDForNativeWindow(const gfx::NativeWindow window) {
  return window;
}

gfx::Rect GetWindowBoundsForClientBounds(View* view,
                                         const gfx::Rect& client_bounds) {
  DCHECK(view);
  HWND hwnd = view->GetWidget()->GetNativeWindow();
  RECT rect = client_bounds.ToRECT();
  DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
  DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
  AdjustWindowRectEx(&rect, style, FALSE, ex_style);
  return gfx::Rect(rect);
}

}  // namespace views