From d1dc041aaf32e266f752c399630c6a5a91816011 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 7 Nov 2013 11:06:00 +0800 Subject: [PATCH] win: Use exe's icon as window icon, fixed #123. --- app/win/resource.h | 5 +++-- browser/native_window_win.cc | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/win/resource.h b/app/win/resource.h index 3ccb12b..d35e16d 100644 --- a/app/win/resource.h +++ b/app/win/resource.h @@ -1,9 +1,10 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by brightray_example.rc + +#define IDR_MAINFRAME 1 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 diff --git a/browser/native_window_win.cc b/browser/native_window_win.cc index f2d899a..5e95a73 100644 --- a/browser/native_window_win.cc +++ b/browser/native_window_win.cc @@ -4,6 +4,7 @@ #include "browser/native_window_win.h" +#include "app/win/resource.h" #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" @@ -32,6 +33,8 @@ namespace { const int kResizeInsideBoundsSize = 5; const int kResizeAreaCornerSize = 16; +HANDLE g_exe_icon = NULL; + // Wrapper of NativeWidgetWin to handle WM_MENUCOMMAND messages, which are // triggered by window menus. class MenuCommandNativeWidget : public views::NativeWidgetWin { @@ -219,6 +222,14 @@ NativeWindowWin::NativeWindowWin(content::WebContents* web_contents, web_view_->SetWebContents(web_contents); OnViewWasResized(); + + if (g_exe_icon == NULL) + g_exe_icon = ::LoadImage(GetModuleHandle(NULL), L"IDR_MAINFRAME", + IMAGE_ICON, 0, 0, 0); + ::SendMessage(window_->GetNativeWindow(), + WM_SETICON, + static_cast(ICON_BIG), + reinterpret_cast(g_exe_icon)); } NativeWindowWin::~NativeWindowWin() { -- 2.7.4