Mercurial > dwindows
diff win/dw.c @ 2852:5018df4f952e
Win/Android/Template: Add return values to dw_window_set_bitmap(_from_data).
Also update the readme regarding this change.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 15 Nov 2022 00:34:20 +0000 |
parents | ee1cfa7d645e |
children | 761b7a12b079 |
line wrap: on
line diff
--- a/win/dw.c Mon Nov 14 22:00:47 2022 +0000 +++ b/win/dw.c Tue Nov 15 00:34:20 2022 +0000 @@ -7693,14 +7693,14 @@ } /* Internal function to set bitmap for the next two functions */ -void _dw_window_set_bitmap(HWND handle, HICON icon, HBITMAP hbitmap) +int _dw_window_set_bitmap(HWND handle, HICON icon, HBITMAP hbitmap) { HBITMAP oldbitmap = 0; HANDLE oldicon = 0; TCHAR tmpbuf[100] = {0}; if (!icon && !hbitmap) - return; + return DW_ERROR_GENERAL; GetClassName(handle, tmpbuf, 99); @@ -7770,6 +7770,7 @@ _dw_redraw(_dw_toplevel_window(handle), TRUE); } } + return DW_ERROR_NONE; } /* @@ -7781,8 +7782,12 @@ * filename: a path to a file (Bitmap on OS/2 or * Windows and a pixmap on Unix, pass * NULL if you use the id param) - */ -void API dw_window_set_bitmap(HWND handle, unsigned long id, const char *filename) + * Returns: + * DW_ERROR_NONE on success. + * DW_ERROR_UNKNOWN if the parameters were invalid. + * DW_ERROR_GENERAL if the bitmap was unable to be loaded. + */ +int API dw_window_set_bitmap(HWND handle, unsigned long id, const char *filename) { HBITMAP hbitmap = 0; HANDLE icon = 0; @@ -7800,8 +7805,10 @@ _dw_get_image_handle(filename, &icon, &hbitmap); #endif } - - _dw_window_set_bitmap(handle, icon, hbitmap); + else + return DW_ERROR_UNKNOWN; + + return _dw_window_set_bitmap(handle, icon, hbitmap); } /* @@ -7814,8 +7821,12 @@ * Bitmap on Windows and a pixmap on Unix, pass * NULL if you use the id param) * len: length of data - */ -void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, const char *data, int len) + * Returns: + * DW_ERROR_NONE on success. + * DW_ERROR_UNKNOWN if the parameters were invalid. + * DW_ERROR_GENERAL if the bitmap was unable to be loaded. + */ +int API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, const char *data, int len) { HBITMAP hbitmap=0; HICON icon=0; @@ -7845,21 +7856,23 @@ { _unlink( file ); free( file ); - return; + return DW_ERROR_GENERAL; } _unlink( file ); free( file ); } if (icon == 0 && hbitmap == 0) - return; + return DW_ERROR_GENERAL; } else if ( id ) { hbitmap = LoadBitmap(_DWInstance, MAKEINTRESOURCE(id)); icon = LoadImage(_DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED); } - - _dw_window_set_bitmap(handle, icon, hbitmap); + else + return DW_ERROR_UNKNOWN; + + return _dw_window_set_bitmap(handle, icon, hbitmap); }