Commit a66e015b authored by robliao's avatar robliao Committed by Commit bot
Browse files

Allow Chrome's Non-Client Area To Be Scaled on DPI Changes

EnableChildWindowDpiMessage enables non-client area updates on DPI changes,
providing DPI appropriate caption buttons as well as the system context menu.

Menubars currently don't appear to scale correctly, but Chrome doesn't use
them, so we're good to go here.


Cr-Commit-Position: refs/heads/master@{#402350}
parent ba9261ea
......@@ -12,6 +12,7 @@
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/lock.h"
#include "base/win/win_util.h"
#include "base/win/wrapped_window_proc.h"
#include "ui/gfx/win/hwnd_util.h"
......@@ -212,6 +213,19 @@ void WindowImpl::Init(HWND parent, const Rect& bounds) {
reinterpret_cast<wchar_t*>(atom), NULL,
window_style_, x, y, width, height,
parent, NULL, NULL, this);
if (hwnd && base::win::IsProcessPerMonitorDpiAware()) {
static auto enable_child_window_dpi_message_func = []() {
// Derived signature; not available in headers.
// This call gets Windows to scale the non-client area when WM_DPICHANGED
// is fired.
using EnableChildWindowDpiMessagePtr = LRESULT (WINAPI*)(HWND, BOOL);
return reinterpret_cast<EnableChildWindowDpiMessagePtr>(
if (enable_child_window_dpi_message_func)
enable_child_window_dpi_message_func(hwnd, TRUE);
// First nccalcszie (during CreateWindow) for captioned windows is
// deliberately ignored so force a second one here to get the right
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment