Permalink
Browse files

Fix #222

  • Loading branch information...
1 parent 3aeb9b1 commit e80e7bfc3ca9d7e20c01079d6bcd32bb5403a90b @milani milani committed Oct 25, 2012
Showing with 21 additions and 19 deletions.
  1. +5 −0 src/appjs_window.cpp
  2. +5 −0 src/native_window/native_window.h
  3. +11 −19 src/native_window/native_window_win.cpp
@@ -198,7 +198,12 @@ Handle<Value> Window::SetIcon(const Arguments& args) {
STRING_TO_ENUM("big", NW_ICONSIZE_BIG)
STRING_TO_ENUM("bigger", NW_ICONSIZE_BIGGER)
+#if defined(__WIN__)
+ window->SetIcon(enumVal, V8StringToWCHAR(args[1]->ToString()));
+#else
window->SetIcon(enumVal, V8StringToChar(args[1]->ToString()));
+#endif
+
return scope.Close(args.This());
}
@@ -50,7 +50,12 @@ class NativeWindow {
static NativeWindow* GetWindow(CefWindowHandle handle);
static NativeWindow* GetWindow(CefRefPtr<CefBrowser> browser);
+#if defined(__WIN__)
+ void SetIcon(NW_ICONSIZE size, WCHAR* path);
+#else
void SetIcon(NW_ICONSIZE size, char* path);
+#endif
+
void Emit(v8::Handle<v8::Value>* args);
void Emit(const char* event);
void Emit(const char* event, v8::Handle<v8::Value> arg);
@@ -85,20 +85,21 @@ void BlurBehind(HWND hwnd, bool enable){
}
}
-void MakeIcon(HICON icon, char* path) {
- Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromFile(ToWChar(path));
+void MakeIcon(HICON* icon, WCHAR* path) {
+ Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromFile(path);
if (bitmap->GetWidth()) {
- bitmap->GetHICON(&icon);
+ bitmap->GetHICON(icon);
delete bitmap;
}
}
-HICON MakeIcon(char* path) {
+HICON MakeIcon(WCHAR* path) {
HICON icon;
- MakeIcon(icon, path);
+ MakeIcon(&icon, path);
return icon;
}
+
void SetNCWidth(HWND hwnd, int left, int right, int top, int bottom){
if (DwmExtendFrameIntoClientArea != NULL) {
MARGINS margins = {left, right, top, bottom};
@@ -189,20 +190,11 @@ void NativeWindow::Init(char* url, Settings* settings) {
WCHAR* wSmallIconPath = icons->getString("small", L"");
WCHAR* wBigIconPath = icons->getString("big", L"");
- Gdiplus::Bitmap* smallIconBitmap = Gdiplus::Bitmap::FromFile(wSmallIconPath);
- Gdiplus::Bitmap* bigIconBitmap = Gdiplus::Bitmap::FromFile(wBigIconPath);
-
- if (smallIconBitmap->GetWidth()) {
- smallIconBitmap->GetHICON(&smallIcon);
- delete[] wSmallIconPath;
- delete smallIconBitmap;
- }
+ smallIcon = MakeIcon(wSmallIconPath);
+ bigIcon = MakeIcon(wSmallIconPath);
- if (bigIconBitmap->GetWidth()) {
- bigIconBitmap->GetHICON(&bigIcon);
- delete[] wBigIconPath;
- delete bigIconBitmap;
- }
+ delete[] wSmallIconPath;
+ delete[] wBigIconPath;
hInstance = (HINSTANCE)GetCurrentModuleHandle();
strcpy(szWindowClass, "AppjsWindow");
@@ -324,7 +316,7 @@ void NativeWindow::Fullscreen(){
// }
-void NativeWindow::SetIcon(NW_ICONSIZE size, char* path) {
+void NativeWindow::SetIcon(NW_ICONSIZE size, WCHAR* path) {
int flag;
switch (size) {
case NW_ICONSIZE_SMALLER: flag = ICON_SMALL; break;

0 comments on commit e80e7bf

Please sign in to comment.