comparison win/dw.c @ 1256:51892bf7fe01

Attempt on Windows to use an icon handle for bitmap buttons before a bitmap... Since XP does not seem to support transparency on bitmaps.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 24 Oct 2011 07:56:20 +0000
parents 363d859e8372
children 35b177e8a0a2
comparison
equal deleted inserted replaced
1255:363d859e8372 1256:51892bf7fe01
5460 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) 5460 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
5461 { 5461 {
5462 HWND tmp; 5462 HWND tmp;
5463 BubbleButton *bubble; 5463 BubbleButton *bubble;
5464 HBITMAP hbitmap = 0; 5464 HBITMAP hbitmap = 0;
5465 HANDLE icon = 0; 5465 HANDLE hicon = 0;
5466 int windowtype = 0, len; 5466 int windowtype = 0, len;
5467 5467
5468 if (!(bubble = calloc(1, sizeof(BubbleButton)))) 5468 if (!(bubble = calloc(1, sizeof(BubbleButton))))
5469 return 0; 5469 return 0;
5470 5470
5471 #ifdef GDIPLUS 5471 #ifdef GDIPLUS
5472 windowtype = BS_BITMAP; 5472 if((hicon = _dw_load_icon(filename)))
5473 hbitmap = _dw_load_bitmap(filename, NULL); 5473 windowtype = BS_ICON;
5474 else
5475 {
5476 hbitmap = _dw_load_bitmap(filename, NULL);
5477 windowtype = BS_BITMAP;
5478 }
5474 #else 5479 #else
5475 windowtype = _dw_get_image_handle(filename, &icon, &hbitmap); 5480 windowtype = _dw_get_image_handle(filename, &hicon, &hbitmap);
5476 #endif 5481 #endif
5477 5482
5478 tmp = CreateWindow( BUTTONCLASSNAME, 5483 tmp = CreateWindow( BUTTONCLASSNAME,
5479 "", 5484 "",
5480 windowtype | WS_CHILD | BS_PUSHBUTTON | WS_CLIPCHILDREN | WS_VISIBLE, 5485 windowtype | WS_CHILD | BS_PUSHBUTTON | WS_CLIPCHILDREN | WS_VISIBLE,
5489 5494
5490 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); 5495 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble);
5491 5496
5492 _create_tooltip(tmp, text); 5497 _create_tooltip(tmp, text);
5493 5498
5494 #ifndef GDIPLUS 5499 if (hicon)
5495 if (icon) 5500 {
5496 { 5501 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hicon);
5497 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) icon); 5502 }
5498 } 5503 else if (hbitmap)
5499 else
5500 #endif
5501 if (hbitmap)
5502 { 5504 {
5503 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap); 5505 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
5504 } 5506 }
5505 return tmp; 5507 return tmp;
5506 } 5508 }