diff --git a/ChangeLog b/ChangeLog index 453370c..f313546 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-01-25 04:13-EST Gregory John Casamento + + * Source/win32/w32_create.m: (-decodeWM_CREATEParams:::) add + code to load and set the HICON into the window. Currently, + an .ico file with the same name as the image specified in + NSIcon or CFBundleIconName needs to be provided in the + resources. + 2010-01-22 Fred Kiefer * Source/x11/XWindowBuffer.m (+windowBufferForWindow:depthInfo:) diff --git a/Source/win32/w32_create.m b/Source/win32/w32_create.m index 2b027af..e3650ee 100644 --- a/Source/win32/w32_create.m +++ b/Source/win32/w32_create.m @@ -28,6 +28,8 @@ #include #include +#include + #include "win32/WIN32Server.h" #include "win32/WIN32Geometry.h" @@ -44,6 +46,9 @@ { WIN_INTERN *win; NSBackingStoreType type = (NSBackingStoreType)((LPCREATESTRUCT)lParam)->lpCreateParams; + NSBundle *bundle = [NSBundle mainBundle]; + NSString *iconName = nil; + NSString *iconPath = nil; // Initialize the window. NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "CREATE", hwnd); @@ -76,6 +81,38 @@ win->useHDC = NO; } + // Find the icon file, assume it has the same name as the "icon" which + // was specified in the bundle's dictionary... + iconName = [[bundle infoDictionary] objectForKey: @"NSIcon"]; + if(iconName == nil) + { + iconName = [[bundle infoDictionary] + objectForKey: @"CFBundleIconFile"]; + } + + // If the icon name is set, get the path... + if(iconName != nil) + { + iconName = [iconName stringByDeletingPathExtension]; + iconPath = [[NSBundle mainBundle] pathForResource: iconName + ofType: @"ico"]; + iconPath = [iconPath stringByStandardizingPath]; + } + + // If the path is set, load the icon file and set it as the + // icon on the window. + if(iconPath != nil) + { + HICON icon = NULL; + const char *cpath = [iconPath cString]; + + icon = LoadImage(NULL, + cpath, + IMAGE_ICON,0,0, + LR_DEFAULTCOLOR|LR_LOADFROMFILE); + SetClassLongPtr(hwnd,GCLP_HICON,(LONG_PTR)icon); + } + return 0; } @end