Mercurial > dwindows
comparison win/dw.c @ 281:2f038ef90a36
Implemented dw_bitmapbutton_new_from_file() on Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 14 Mar 2003 18:20:50 +0000 |
parents | df0665ba147f |
children | 54aafc134652 |
comparison
equal
deleted
inserted
replaced
280:030188d45a69 | 281:2f038ef90a36 |
---|---|
4193 (LPARAM) hbitmap); | 4193 (LPARAM) hbitmap); |
4194 return tmp; | 4194 return tmp; |
4195 } | 4195 } |
4196 | 4196 |
4197 /* | 4197 /* |
4198 * Create a new bitmap button window (widget) to be packed from a file. | |
4199 * Parameters: | |
4200 * text: Bubble help text to be displayed. | |
4201 * id: An ID to be used with dw_window_from_id() or 0L. | |
4202 * filename: Name of the file, omit extention to have | |
4203 * DW pick the appropriate file extension. | |
4204 * (BMP on OS/2 or Windows, XPM on Unix) | |
4205 */ | |
4206 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) | |
4207 { | |
4208 HWND tmp; | |
4209 BubbleButton *bubble; | |
4210 HBITMAP hbitmap; | |
4211 char *file = malloc(strlen(filename) + 5); | |
4212 | |
4213 if(!file || !(bubble = calloc(1, sizeof(BubbleButton)))) | |
4214 { | |
4215 if(file) | |
4216 free(file); | |
4217 return 0; | |
4218 } | |
4219 | |
4220 strcpy(file, filename); | |
4221 | |
4222 /* check if we can read from this file (it exists and read permission) */ | |
4223 if(access(file, 04) != 0) | |
4224 { | |
4225 /* Try with .bmp extention */ | |
4226 strcat(file, ".bmp"); | |
4227 if(access(file, 04) != 0) | |
4228 { | |
4229 free(bubble); | |
4230 free(file); | |
4231 return 0; | |
4232 } | |
4233 } | |
4234 | |
4235 hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); | |
4236 | |
4237 tmp = CreateWindow(BUTTONCLASSNAME, | |
4238 "", | |
4239 WS_CHILD | BS_PUSHBUTTON | | |
4240 BS_BITMAP | WS_CLIPCHILDREN | | |
4241 WS_VISIBLE, | |
4242 0,0,2000,1000, | |
4243 DW_HWND_OBJECT, | |
4244 (HMENU)id, | |
4245 DWInstance, | |
4246 NULL); | |
4247 | |
4248 bubble->id = id; | |
4249 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); | |
4250 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; | |
4251 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); | |
4252 | |
4253 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble); | |
4254 | |
4255 SendMessage(tmp, BM_SETIMAGE, | |
4256 (WPARAM) IMAGE_BITMAP, | |
4257 (LPARAM) hbitmap); | |
4258 free(file); | |
4259 return tmp; | |
4260 } | |
4261 | |
4262 /* | |
4198 * Create a new spinbutton window (widget) to be packed. | 4263 * Create a new spinbutton window (widget) to be packed. |
4199 * Parameters: | 4264 * Parameters: |
4200 * text: The text to be display by the static text widget. | 4265 * text: The text to be display by the static text widget. |
4201 * id: An ID to be used with dw_window_from_id() or 0L. | 4266 * id: An ID to be used with dw_window_from_id() or 0L. |
4202 */ | 4267 */ |