Mercurial > dwindows
diff os2/dw.c @ 257:9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
to be filled in shortly.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 20 Feb 2003 20:19:09 +0000 |
parents | 00d2b1bcf036 |
children | bf8b907f8a29 |
line wrap: on
line diff
--- a/os2/dw.c Thu Feb 20 17:55:56 2003 +0000 +++ b/os2/dw.c Thu Feb 20 20:19:09 2003 +0000 @@ -5813,6 +5813,33 @@ } /* + * Obtains an icon from a file. + * Parameters: + * filename: Name of the file, omit extention to have + * DW pick the appropriate file extension. + * (ICO on OS/2 or Windows, XPM on Unix) + */ +unsigned long API dw_icon_load_from_file(char *filename) +{ + char *file = alloca(strlen(filename) + 5); + + if(!file) + 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, ".ico"); + if(access(file, 04) != 0) + return 0; + } + return WinLoadFileIcon(file, FALSE); +} + +/* * Frees a loaded resource in OS/2 and Windows. * Parameters: * handle: Handle to icon returned by dw_icon_load().