comparison win/dw.c @ 1257:35b177e8a0a2

Basically a repeat of that last fix except for the data version of the function.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 24 Oct 2011 08:01:42 +0000
parents 51892bf7fe01
children 61d0c5f84644
comparison
equal deleted inserted replaced
1256:51892bf7fe01 1257:35b177e8a0a2
5519 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) 5519 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
5520 { 5520 {
5521 HWND tmp; 5521 HWND tmp;
5522 BubbleButton *bubble; 5522 BubbleButton *bubble;
5523 HBITMAP hbitmap = 0; 5523 HBITMAP hbitmap = 0;
5524 HANDLE icon = 0; 5524 HANDLE hicon = 0;
5525 char *file; 5525 char *file;
5526 FILE *fp; 5526 FILE *fp;
5527 int windowtype; 5527 int windowtype;
5528 5528
5529 if ( !(bubble = calloc(1, sizeof(BubbleButton))) ) 5529 if ( !(bubble = calloc(1, sizeof(BubbleButton))) )
5535 if ( fp != NULL ) 5535 if ( fp != NULL )
5536 { 5536 {
5537 fwrite( data, 1, len, fp ); 5537 fwrite( data, 1, len, fp );
5538 fclose( fp ); 5538 fclose( fp );
5539 #ifdef GDIPLUS 5539 #ifdef GDIPLUS
5540 windowtype = BS_BITMAP; 5540 if((hicon = _dw_load_icon(file)))
5541 hbitmap = _dw_load_bitmap(file, NULL); 5541 windowtype = BS_ICON;
5542 else
5543 {
5544 hbitmap = _dw_load_bitmap(file, NULL);
5545 windowtype = BS_BITMAP;
5546 }
5542 #else 5547 #else
5543 if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */ 5548 if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */
5544 { 5549 {
5545 hbitmap = (HBITMAP)LoadImage( NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); 5550 hbitmap = (HBITMAP)LoadImage( NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
5546 windowtype = BS_BITMAP; 5551 windowtype = BS_BITMAP;
5547 } 5552 }
5548 else /* otherwise its assumed to be an ico */ 5553 else /* otherwise its assumed to be an ico */
5549 { 5554 {
5550 icon = LoadImage( NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); 5555 hicon = LoadImage( NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
5551 windowtype = BS_ICON; 5556 windowtype = BS_ICON;
5552 } 5557 }
5553 #endif 5558 #endif
5554 } 5559 }
5555 else 5560 else
5578 5583
5579 SetWindowLongPtr( tmp, GWLP_USERDATA, (LONG_PTR)bubble ); 5584 SetWindowLongPtr( tmp, GWLP_USERDATA, (LONG_PTR)bubble );
5580 5585
5581 _create_tooltip(tmp, text); 5586 _create_tooltip(tmp, text);
5582 5587
5583 if ( icon ) 5588 if ( hicon )
5584 { 5589 {
5585 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) icon); 5590 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) hicon);
5586 } 5591 }
5587 else if( hbitmap ) 5592 else if( hbitmap )
5588 { 5593 {
5589 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap); 5594 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
5590 } 5595 }