win: Set native window's background color

This commit is contained in:
Cheng Zhao 2015-10-23 11:17:14 +08:00
Родитель 6182e4ce81
Коммит 4a6134f3f7
1 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -42,6 +42,7 @@
#elif defined(OS_WIN)
#include "atom/browser/ui/views/win_frame_view.h"
#include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h"
#include "skia/ext/skia_utils_win.h"
#include "ui/base/win/shell.h"
#include "ui/gfx/win/dpi.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
@ -230,14 +231,22 @@ NativeWindowViews::NativeWindowViews(
SetLayoutManager(new MenuLayout(this, kMenuBarHeight));
// web views' background color.
std::string background_color = "#fff";
options.Get(switches::kBackgroundColor, &background_color);
set_background(views::Background::CreateSolidBackground(
ParseHexColor(background_color)));
SkColor background_color = SK_ColorWHITE;
std::string color_name;
if (options.Get(switches::kBackgroundColor, &color_name))
background_color = ParseHexColor(color_name);
set_background(views::Background::CreateSolidBackground(background_color));
AddChildView(web_view_);
#if defined(OS_WIN)
// Set the background color of native window.
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
ULONG_PTR previous_brush = SetClassLongPtr(
GetAcceleratedWidget(), GCLP_HBRBACKGROUND, (LONG)brush);
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
// Save initial window state.
if (fullscreen)
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;