Mercurial > dwindows
comparison win/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 | 0f9a185deeb6 |
children | bf8b907f8a29 |
comparison
equal
deleted
inserted
replaced
256:63d68387d924 | 257:9ea4ac9a097f |
---|---|
5853 { | 5853 { |
5854 return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id)); | 5854 return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id)); |
5855 } | 5855 } |
5856 | 5856 |
5857 /* | 5857 /* |
5858 * Obtains an icon from a file. | |
5859 * Parameters: | |
5860 * filename: Name of the file, omit extention to have | |
5861 * DW pick the appropriate file extension. | |
5862 * (ICO on OS/2 or Windows, XPM on Unix) | |
5863 */ | |
5864 unsigned long API dw_icon_load_from_file(char *filename) | |
5865 { | |
5866 char *file = malloc(strlen(filename) + 5); | |
5867 HANDLE icon; | |
5868 | |
5869 if(!file) | |
5870 return 0; | |
5871 | |
5872 strcpy(file, filename); | |
5873 | |
5874 /* check if we can read from this file (it exists and read permission) */ | |
5875 if(access(file, 04) != 0) | |
5876 { | |
5877 /* Try with .bmp extention */ | |
5878 strcat(file, ".ico"); | |
5879 if(access(file, 04) != 0) | |
5880 { | |
5881 free(file); | |
5882 return 0; | |
5883 } | |
5884 } | |
5885 icon = LoadImage(NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); | |
5886 free(file); | |
5887 return (unsigned long)icon; | |
5888 } | |
5889 | |
5890 /* | |
5858 * Frees a loaded resource in OS/2 and Windows. | 5891 * Frees a loaded resource in OS/2 and Windows. |
5859 * Parameters: | 5892 * Parameters: |
5860 * handle: Handle to icon returned by dw_icon_load(). | 5893 * handle: Handle to icon returned by dw_icon_load(). |
5861 */ | 5894 */ |
5862 void API dw_icon_free(unsigned long handle) | 5895 void API dw_icon_free(unsigned long handle) |