comparison win/dw.c @ 1252:575663435272

Fixed not accounting for the NULL terminator on Windows when converting to wide characters. Also fixed not initializing a variable with the new code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 24 Oct 2011 03:44:24 +0000
parents 7809be48de7d
children 363d859e8372
comparison
equal deleted inserted replaced
1251:7809be48de7d 1252:575663435272
400 strcpy( file, filename ); 400 strcpy( file, filename );
401 strcat( file, image_exts[i] ); 401 strcat( file, image_exts[i] );
402 if ( access( file, 04 ) == 0 ) 402 if ( access( file, 04 ) == 0 )
403 { 403 {
404 /* Convert to wide format */ 404 /* Convert to wide format */
405 MultiByteToWideChar(CP_ACP, 0, file, strlen(file), wfile, wclen); 405 MultiByteToWideChar(CP_ACP, 0, file, strlen(file)+1, wfile, wclen);
406 if(!GdipCreateBitmapFromFile(wfile, &image)) 406 if(!GdipCreateBitmapFromFile(wfile, &image))
407 return image; 407 return image;
408 } 408 }
409 } 409 }
410 return NULL; 410 return NULL;
5833 */ 5833 */
5834 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) 5834 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
5835 { 5835 {
5836 HBITMAP hbitmap; 5836 HBITMAP hbitmap;
5837 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); 5837 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
5838 HICON icon; 5838 HICON icon = 0;
5839 HICON oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0); 5839 HICON oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
5840 5840
5841 if(id) 5841 if(id)
5842 { 5842 {
5843 hbitmap = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_SHARED); 5843 hbitmap = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_SHARED);