Mercurial > dwindows
changeset 303:464b5e46b313
Create the bitmap button even if the bitmap file does not exist.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 28 Mar 2003 21:19:07 +0000 |
parents | 7c1770e3fe08 |
children | c28c0a804442 |
files | win/dw.c |
diffstat | 1 files changed, 19 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/win/dw.c Thu Mar 27 11:14:25 2003 +0000 +++ b/win/dw.c Fri Mar 28 21:19:07 2003 +0000 @@ -4222,7 +4222,7 @@ { HWND tmp; BubbleButton *bubble; - HBITMAP hbitmap; + HBITMAP hbitmap = 0; char *file = malloc(strlen(filename) + 5); if(!file || !(bubble = calloc(1, sizeof(BubbleButton)))) @@ -4232,23 +4232,6 @@ return 0; } - strcpy(file, filename); - - /* check if we can read from this file (it exists and read permission) */ - if(access(file, 04) != 0) - { - /* Try with .bmp extention */ - strcat(file, ".bmp"); - if(access(file, 04) != 0) - { - free(bubble); - free(file); - return 0; - } - } - - hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); - tmp = CreateWindow(BUTTONCLASSNAME, "", WS_CHILD | BS_PUSHBUTTON | @@ -4267,9 +4250,24 @@ SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble); - SendMessage(tmp, BM_SETIMAGE, - (WPARAM) IMAGE_BITMAP, - (LPARAM) hbitmap); + strcpy(file, filename); + + /* check if we can read from this file (it exists and read permission) */ + if(access(file, 04) == 0) + hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + else + { + /* Try with .bmp extention */ + strcat(file, ".bmp"); + if(access(file, 04) == 0) + hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + } + + + if(hbitmap) + SendMessage(tmp, BM_SETIMAGE, + (WPARAM) IMAGE_BITMAP, + (LPARAM) hbitmap); free(file); return tmp; }