win: Use exe's icon as window icon, fixed #123.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 7 Nov 2013 03:06:00 +0000 (11:06 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 7 Nov 2013 03:06:25 +0000 (11:06 +0800)
app/win/resource.h
browser/native_window_win.cc

index 3ccb12b..d35e16d 100644 (file)
@@ -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
index f2d899a..5e95a73 100644 (file)
@@ -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<WPARAM>(ICON_BIG),
+                reinterpret_cast<LPARAM>(g_exe_icon));
 }
 
 NativeWindowWin::~NativeWindowWin() {