Skip to content

Commit

Permalink
Fix #222
Browse files Browse the repository at this point in the history
  • Loading branch information
milani committed Oct 25, 2012
1 parent 3aeb9b1 commit e80e7bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/appjs_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
5 changes: 5 additions & 0 deletions src/native_window/native_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 11 additions & 19 deletions src/native_window/native_window_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e80e7bf

Please sign in to comment.