win: Use exe's icon as window icon, fixed #123.

This commit is contained in:
Cheng Zhao 2013-11-07 11:06:00 +08:00
parent 85243edf4e
commit d1dc041aaf
2 changed files with 14 additions and 2 deletions

View 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

View 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() {