source: trunk/src/user32/loadres.cpp@ 4558

Last change on this file since 4558 was 4558, checked in by sandervl, 25 years ago

extra exports for gdi32; moved 4 apis back into gdi32

File size: 21.9 KB
Line 
1/* $Id: loadres.cpp,v 1.32 2000-11-05 18:49:07 sandervl Exp $ */
2
3/*
4 * Win32 resource API functions for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 *
8 * Parts based on Wine code (objects\bitmap.c, loader\resource.c, objects\cursoricon.c):
9 *
10 * Copyright 1993 Alexandre Julliard
11 * 1993 Robert J. Amstadt
12 * 1996 Martin Von Loewis
13 * 1997 Alex Korobka
14 * 1998 Turchanov Sergey
15 * 1998 Huw D M Davies
16 *
17 * Project Odin Software License can be found in LICENSE.TXT
18 *
19 */
20#include <os2win.h>
21#include <user32.h>
22#include <heapstring.h>
23#include <oslibres.h>
24#include <win\virtual.h>
25#include "dib.h"
26#include "initterm.h"
27#include <win\cursoricon.h>
28#include <winres.h>
29
30#define DBG_LOCALLOG DBG_loadres
31#include "dbglocal.h"
32
33//******************************************************************************
34//******************************************************************************
35INT WIN32API LoadStringA(HINSTANCE instance, UINT resource_id,
36 LPSTR buffer, INT buflen )
37{
38 INT retval;
39 LPWSTR buffer2 = NULL;
40
41 if (buffer && buflen)
42 buffer2 = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, buflen * 2 );
43
44 retval = LoadStringW(instance,resource_id,buffer2,buflen);
45
46 if (buffer2)
47 {
48 if (retval) {
49 lstrcpynWtoA( buffer, buffer2, buflen );
50 retval = lstrlenA( buffer );
51 }
52 else
53 *buffer = 0;
54 HeapFree( GetProcessHeap(), 0, buffer2 );
55 }
56 return retval;
57}
58//******************************************************************************
59//******************************************************************************
60int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer)
61{
62 WCHAR *p;
63 int string_num;
64 int i = 0;
65 HRSRC hRes;
66
67 /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out
68 * 20 - 31. */
69 hRes = FindResourceW(hinst, (LPWSTR)(((wID>>4)&0xffff)+1), RT_STRINGW);
70 if(hRes == NULL) {
71 dprintf(("LoadStringW NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
72 *lpBuffer = 0;
73 return 0;
74 }
75
76 p = (LPWSTR)LockResource(LoadResource(hinst, hRes));
77 if(p) {
78 string_num = wID & 0x000f;
79 for (i = 0; i < string_num; i++)
80 p += *p + 1;
81
82 if (lpBuffer == NULL) return *p;
83 i = min(cchBuffer - 1, *p);
84 if (i > 0) {
85 memcpy(lpBuffer, p + 1, i * sizeof (WCHAR));
86 lpBuffer[i] = (WCHAR) 0;
87 }
88 else {
89 if (cchBuffer > 1) {
90 lpBuffer[0] = (WCHAR) 0;
91 return 0;
92 }
93 }
94 }
95
96#ifdef DEBUG_ENABLELOG_LEVEL2
97 if(i) {
98 char *astring = (char *)HEAP_strdupWtoA(GetProcessHeap(), 0, lpBuffer);
99 dprintf(("LoadStringW from %X, id %d %s\n", hinst, wID, astring));
100 HEAP_free(astring);
101 }
102#else
103 dprintf(("LoadStringW from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
104#endif
105 return(i);
106}
107//******************************************************************************
108//******************************************************************************
109HICON LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon, DWORD cxDesired,
110 DWORD cyDesired, DWORD fuLoad)
111{
112 HICON hIcon;
113 HANDLE hMapping = 0;
114 char *ptr = NULL;
115 HRSRC hRes;
116 LPSTR restype = RT_ICONA;
117
118 dprintf(("USER32: LoadIconA %x %x (%d,%d) %x", hinst, lpszIcon, cxDesired, cyDesired, fuLoad));
119
120 if(fuLoad & LR_LOADFROMFILE)
121 {
122 hMapping = VIRTUAL_MapFileA( lpszIcon, (LPVOID *)&ptr, TRUE);
123 if(hMapping == INVALID_HANDLE_VALUE)
124 return 0;
125 hIcon = OSLibWinCreatePointer(ptr);
126 CloseHandle(hMapping);
127 }
128 else
129 {
130 if(!hinst)
131 {
132 hRes = FindResourceA(hInstanceUser32,lpszIcon,RT_ICONA);
133 if(!hRes) {
134 hRes = FindResourceA(hInstanceUser32,lpszIcon,RT_GROUP_ICONA);
135 restype = RT_GROUP_ICONA;
136 }
137 if(hRes)
138 {
139 hIcon = OSLibWinCreateIcon(ConvertResourceToOS2(hInstanceUser32, restype, hRes));
140 }
141 else hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON));
142 }
143 else
144 { //not a system icon
145 hRes = FindResourceA(hinst,lpszIcon,RT_ICONA);
146 if(!hRes) {
147 hRes = FindResourceA(hinst,lpszIcon,RT_GROUP_ICONA);
148 restype = RT_GROUP_ICONA;
149 }
150 if(hRes) {
151 hIcon = OSLibWinCreateIcon(ConvertResourceToOS2(hinst, restype, hRes));
152 }
153 else hIcon = 0;
154 }
155 }
156 dprintf(("LoadIconA (%X) returned %x\n", hinst, hIcon));
157
158 return(hIcon);
159}
160//******************************************************************************
161//******************************************************************************
162HICON LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon, DWORD cxDesired,
163 DWORD cyDesired, DWORD fuLoad)
164{
165 HICON hIcon;
166 HANDLE hMapping = 0;
167 char *ptr = NULL;
168 HRSRC hRes;
169 LPSTR restype = RT_ICONA;
170
171 if(fuLoad & LR_LOADFROMFILE)
172 {
173 hMapping = VIRTUAL_MapFileW( lpszIcon, (LPVOID *)&ptr, TRUE);
174 if(hMapping == INVALID_HANDLE_VALUE)
175 return 0;
176 hIcon = OSLibWinCreatePointer(ptr);
177 CloseHandle(hMapping);
178 }
179 else
180 {
181 if (!hinst)
182 {
183 hRes = FindResourceW(hInstanceUser32,lpszIcon,RT_ICONW);
184 if(!hRes) {
185 hRes = FindResourceW(hInstanceUser32,lpszIcon,RT_GROUP_ICONW);
186 restype = RT_GROUP_ICONA;
187 }
188 if(hRes)
189 {
190 hIcon = OSLibWinCreateIcon(ConvertResourceToOS2(hInstanceUser32, restype, hRes));
191 }
192 else hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON));
193 }
194 else
195 {//not a system icon
196 hRes = FindResourceW(hinst,lpszIcon,RT_ICONW);
197 if(!hRes) {
198 hRes = FindResourceW(hinst,lpszIcon,RT_GROUP_ICONW);
199 restype = RT_GROUP_ICONA;
200 }
201 if(hRes) {
202 hIcon = OSLibWinCreateIcon(ConvertResourceToOS2(hinst, restype, hRes));
203 }
204 else hIcon = 0;
205 }
206 }
207 dprintf(("LoadIconW (%X) returned %x\n", hinst, hIcon));
208
209 return(hIcon);
210}
211//******************************************************************************
212//******************************************************************************
213HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon)
214{
215 return LoadIconA(hinst, lpszIcon, 0, 0, 0);
216}
217//******************************************************************************
218//******************************************************************************
219HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
220{
221 return LoadIconW(hinst, lpszIcon, 0, 0, 0);
222}
223//******************************************************************************
224//******************************************************************************
225HCURSOR LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor, DWORD cxDesired,
226 DWORD cyDesired, DWORD fuLoad)
227{
228 HCURSOR hCursor;
229 HANDLE hMapping = 0;
230 char *ptr = NULL;
231 HRSRC hRes;
232 LPSTR restype = RT_CURSORA;
233
234 if(fuLoad & LR_LOADFROMFILE)
235 {
236 hMapping = VIRTUAL_MapFileA( lpszCursor, (LPVOID *)&ptr, TRUE);
237 if(hMapping == INVALID_HANDLE_VALUE)
238 return 0;
239 hCursor = OSLibWinCreatePointer(ptr);
240 CloseHandle(hMapping);
241 }
242 else
243 {
244 if(!hinst)
245 {
246 hRes = FindResourceA(hInstanceUser32,lpszCursor,RT_CURSORA);
247 if(!hRes) {
248 hRes = FindResourceA(hInstanceUser32,lpszCursor,RT_GROUP_CURSORA);
249 restype = RT_GROUP_CURSORA;
250 }
251 if(hRes)
252 {
253 hCursor = OSLibWinCreatePointer(ConvertResourceToOS2(hInstanceUser32, restype, hRes));
254 }
255 else hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor,GetSystemMetrics(SM_CXCURSOR),GetSystemMetrics(SM_CYCURSOR));
256 }
257 else
258 { //not a system icon
259 hRes = FindResourceA(hinst,lpszCursor,RT_CURSORA);
260 if(!hRes) {
261 hRes = FindResourceA(hinst,lpszCursor,RT_GROUP_CURSORA);
262 restype = RT_GROUP_CURSORA;
263 }
264 if(hRes) {
265 hCursor = OSLibWinCreatePointer(ConvertResourceToOS2(hinst, restype, hRes));
266 }
267 else hCursor = 0;
268 }
269 }
270 if(HIWORD(lpszCursor)) {
271 dprintf(("LoadCursorA %s from %x returned %x\n", lpszCursor, hinst, hCursor));
272 }
273 else dprintf(("LoadCursorA %x from %x returned %x\n", lpszCursor, hinst, hCursor));
274
275 return(hCursor);
276}
277//******************************************************************************
278//******************************************************************************
279HCURSOR LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor, DWORD cxDesired,
280 DWORD cyDesired, DWORD fuLoad)
281{
282 HCURSOR hCursor;
283 HANDLE hMapping = 0;
284 char *ptr = NULL;
285 HRSRC hRes;
286 LPSTR restype = RT_CURSORA;
287
288 if(fuLoad & LR_LOADFROMFILE)
289 {
290 hMapping = VIRTUAL_MapFileW( lpszCursor, (LPVOID *)&ptr, TRUE);
291 if(hMapping == INVALID_HANDLE_VALUE)
292 return 0;
293 hCursor = OSLibWinCreatePointer(ptr);
294 CloseHandle(hMapping);
295 }
296 else
297 {
298 if(!hinst)
299 {
300 hRes = FindResourceW(hInstanceUser32,lpszCursor,RT_CURSORW);
301 if(!hRes) {
302 hRes = FindResourceW(hInstanceUser32,lpszCursor,RT_GROUP_CURSORW);
303 restype = RT_GROUP_CURSORA;
304 }
305 if(hRes)
306 {
307 hCursor = OSLibWinCreatePointer(ConvertResourceToOS2(hInstanceUser32, restype, hRes));
308 }
309 else hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor,GetSystemMetrics(SM_CXCURSOR),GetSystemMetrics(SM_CYCURSOR));
310 }
311 else
312 { //not a system icon
313 hRes = FindResourceW(hinst,lpszCursor,RT_CURSORW);
314 if(!hRes) {
315 hRes = FindResourceW(hinst,lpszCursor,RT_GROUP_CURSORW);
316 restype = RT_GROUP_CURSORA;
317 }
318 if(hRes) {
319 hCursor = OSLibWinCreatePointer(ConvertResourceToOS2(hinst, restype, hRes));
320 }
321 else hCursor = 0;
322 }
323 }
324 dprintf(("LoadCursorW (%X) returned %x\n", hinst, hCursor));
325
326 return(hCursor);
327}
328//******************************************************************************
329//******************************************************************************
330HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
331{
332 return LoadCursorA(hinst, lpszCursor, 0, 0, 0);
333}
334//******************************************************************************
335//******************************************************************************
336HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
337{
338 return LoadCursorW(hinst, lpszCursor, 0, 0, 0);
339}
340//******************************************************************************
341//******************************************************************************
342BOOL IsSystemBitmap(ULONG id)
343{
344 switch(id)
345 {
346 case OBM_UPARROW:
347 case OBM_DNARROW:
348 case OBM_RGARROW:
349 case OBM_LFARROW:
350 case OBM_RESTORE:
351 case OBM_RESTORED:
352 case OBM_UPARROWD:
353 case OBM_DNARROWD:
354 case OBM_RGARROWD:
355 case OBM_LFARROWD:
356 case OBM_OLD_UPARROW:
357 case OBM_OLD_DNARROW:
358 case OBM_OLD_RGARROW:
359 case OBM_OLD_LFARROW:
360 case OBM_CHECK:
361 case OBM_RADIOCHECK:
362 case OBM_CHECKBOXES:
363 case OBM_BTNCORNERS:
364 case OBM_COMBO:
365 case OBM_REDUCE:
366 case OBM_REDUCED:
367 case OBM_ZOOM:
368 case OBM_ZOOMD:
369 case OBM_SIZE:
370 case OBM_CLOSE:
371 case OBM_MNARROW:
372 case OBM_UPARROWI:
373 case OBM_DNARROWI:
374 case OBM_RGARROWI:
375 case OBM_LFARROWI:
376 case OBM_CLOSED:
377 case OBM_OLD_CLOSE:
378 case OBM_BTSIZE:
379 case OBM_OLD_REDUCE:
380 case OBM_OLD_ZOOM:
381 case OBM_OLD_RESTORE:
382 case OBM_CONTEXTHELP:
383 case OBM_CONTEXTHELPD:
384 case OBM_TRTYPE:
385 return TRUE;
386
387 default:
388 return FALSE;
389 }
390}
391//******************************************************************************
392//NOTE: LR_CREATEDIBSECTION flag doesn't work (crash in GDI32)!
393//******************************************************************************
394HANDLE LoadBitmapA(HINSTANCE hinst, LPCSTR lpszName, int cxDesired, int cyDesired,
395 UINT fuLoad)
396{
397 HBITMAP hbitmap = 0;
398 HDC hdc;
399 HRSRC hRsrc;
400 HGLOBAL handle, hMapping = 0;
401 char *ptr = NULL;
402 BITMAPINFO *info, *fix_info=NULL;
403 HGLOBAL hFix;
404 int size;
405
406 if (!(fuLoad & LR_LOADFROMFILE)) {
407 if (!(hRsrc = FindResourceA( hinst, lpszName, RT_BITMAPA ))) return 0;
408 if (!(handle = LoadResource( hinst, hRsrc ))) return 0;
409
410 if ((info = (BITMAPINFO *)LockResource( handle )) == NULL) return 0;
411 }
412 else
413 {
414 hMapping = VIRTUAL_MapFileA( lpszName, (LPVOID *)&ptr, TRUE);
415 if (hMapping == INVALID_HANDLE_VALUE) {
416 //TODO: last err set to ERROR_OPEN_FAILED if file not found; correct??
417 dprintf(("LoadBitmapA: failed to load file %s (lasterr=%x)", lpszName, GetLastError()));
418 return 0;
419 }
420 info = (BITMAPINFO *)(ptr + sizeof(BITMAPFILEHEADER));
421 }
422
423 //TODO: This has to be removed once pe2lx stores win32 resources!!!
424 if (info->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) &&
425 info->bmiHeader.biSize != sizeof(BITMAPINFOHEADER))
426 {//assume it contains a file header first
427 info = (BITMAPINFO *)((char *)info + sizeof(BITMAPFILEHEADER));
428 }
429
430 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) {
431 size = sizeof(BITMAPINFOHEADER) +
432 (sizeof (RGBTRIPLE) << ((BITMAPCOREHEADER *)info)->bcBitCount);
433 } else
434 size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS);
435
436 if ((hFix = GlobalAlloc(0, size)) != NULL) fix_info = (BITMAPINFO *)GlobalLock(hFix);
437 if (fix_info) {
438 BYTE pix;
439
440 if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) {
441 ULONG colors;
442 ULONG *p, *q;
443
444 memset (fix_info, 0, sizeof (BITMAPINFOHEADER));
445 fix_info->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
446 fix_info->bmiHeader.biWidth = ((BITMAPCOREHEADER *)info)->bcWidth;
447 fix_info->bmiHeader.biHeight = ((BITMAPCOREHEADER *)info)->bcHeight;
448 fix_info->bmiHeader.biPlanes = ((BITMAPCOREHEADER *)info)->bcPlanes;
449 fix_info->bmiHeader.biBitCount = ((BITMAPCOREHEADER *)info)->bcBitCount;
450
451 p = (PULONG)((char *)info + sizeof(BITMAPCOREHEADER));
452 q = (PULONG)((char *)fix_info + sizeof(BITMAPINFOHEADER));
453 for (colors = 1 << fix_info->bmiHeader.biBitCount; colors > 0; colors--) {
454 *q = *p & 0x00FFFFFFUL;
455 q++;
456 p = (PULONG)((char *)p + sizeof (RGBTRIPLE));
457 }
458 } else
459 memcpy(fix_info, info, size);
460
461 size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS);
462 pix = *((LPBYTE)info + size);
463 DIB_FixColorsToLoadflags(fix_info, fuLoad, pix);
464 if ((hdc = GetDC(0)) != 0) {
465 char *bits = (char *)info + size;
466 if (fuLoad & LR_CREATEDIBSECTION) {
467 DIBSECTION dib;
468 hbitmap = CreateDIBSection(hdc, fix_info, DIB_RGB_COLORS, NULL, 0, 0);
469 GetObjectA(hbitmap, sizeof(DIBSECTION), &dib);
470 SetDIBits(hdc, hbitmap, 0, dib.dsBm.bmHeight, bits, info,
471 DIB_RGB_COLORS);
472 }
473 else {
474// if(fix_info->bmiHeader.biBitCount == 1) {
475// hbitmap = CreateBitmap(fix_info->bmiHeader.biWidth,
476// fix_info->bmiHeader.biHeight,
477// fix_info->bmiHeader.biPlanes,
478// fix_info->bmiHeader.biBitCount,
479// (PVOID)bits);
480// }
481// else {
482 hbitmap = CreateDIBitmap(hdc, &fix_info->bmiHeader, CBM_INIT,
483 bits, fix_info, DIB_RGB_COLORS );
484 if(hbitmap == 0) {
485 dprintf(("LoadBitmapA: CreateDIBitmap failed!!"));
486 }
487// }
488 }
489 ReleaseDC( 0, hdc );
490 }
491 GlobalUnlock(hFix);
492 GlobalFree(hFix);
493 }
494 if (fuLoad & LR_LOADFROMFILE) CloseHandle( hMapping );
495 return hbitmap;
496}
497//******************************************************************************
498//TODO: No support for RT_NEWBITMAP
499//******************************************************************************
500HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
501{
502 HBITMAP hBitmap = 0;
503
504 if (!hinst)
505 {
506 if(IsSystemBitmap((ULONG)lpszBitmap))
507 {
508 hBitmap = LoadBitmapA(hInstanceUser32, lpszBitmap, 0, 0, 0);
509 }
510 }
511 if(!hBitmap)
512 hBitmap = LoadBitmapA(hinst, lpszBitmap, 0, 0, 0);
513
514 if(HIWORD(lpszBitmap)) {
515 dprintf(("LoadBitmapA %x %s returned %08xh\n", hinst, lpszBitmap, hBitmap));
516 }
517 else dprintf(("LoadBitmapA %x %x returned %08xh\n", hinst, lpszBitmap, hBitmap));
518
519 return(hBitmap);
520}
521//******************************************************************************
522//TODO: No support for RT_NEWBITMAP
523//******************************************************************************
524HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
525{
526 HBITMAP hBitmap = 0;
527
528 if(HIWORD(lpszBitmap) != 0)
529 lpszBitmap = (LPWSTR)UnicodeToAsciiString((LPWSTR)lpszBitmap);
530
531 hBitmap = LoadBitmapA((hinst == 0) ? hInstanceUser32:hinst, (LPSTR)lpszBitmap, 0, 0, 0);
532
533 if(HIWORD(lpszBitmap) != 0)
534 FreeAsciiString((LPSTR)lpszBitmap);
535
536 if(HIWORD(lpszBitmap)) {
537 dprintf(("LoadBitmapW %x %s returned %08xh\n", hinst, lpszBitmap, hBitmap));
538 }
539 else dprintf(("LoadBitmapW %x %x returned %08xh\n", hinst, lpszBitmap, hBitmap));
540
541 return(hBitmap);
542}
543//******************************************************************************
544//TODO: Far from complete, but works for loading resources from exe
545//fuLoad flag ignored
546//******************************************************************************
547HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType,
548 int cxDesired, int cyDesired, UINT fuLoad)
549{
550 HANDLE hRet = 0;
551
552 if(HIWORD(lpszName)) {
553 dprintf(("LoadImageA NOT COMPLETE %x %s %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired));
554 }
555 else dprintf(("LoadImageA NOT COMPLETE %x %x %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired));
556
557 if(fuLoad & LR_DEFAULTSIZE) {
558 if (uType == IMAGE_ICON) {
559 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXICON);
560 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYICON);
561 }
562 else if (uType == IMAGE_CURSOR) {
563 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR);
564 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYCURSOR);
565 }
566 }
567 if (fuLoad & LR_LOADFROMFILE) fuLoad &= ~LR_SHARED;
568
569 switch(uType) {
570 case IMAGE_BITMAP:
571 hRet = (HANDLE)LoadBitmapA(hinst, lpszName, cxDesired, cyDesired, fuLoad);
572 break;
573 case IMAGE_CURSOR:
574 hRet = (HANDLE)LoadCursorA(hinst, lpszName, cxDesired, cyDesired, fuLoad);
575 break;
576 case IMAGE_ICON:
577 hRet = (HANDLE)LoadIconA(hinst, lpszName, cxDesired, cyDesired, fuLoad);
578 break;
579 default:
580 dprintf(("LoadImageA: unsupported type %d!!", uType));
581 return 0;
582 }
583 dprintf(("LoadImageA returned %x\n", (int)hRet));
584
585 return(hRet);
586}
587//******************************************************************************
588//******************************************************************************
589HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType,
590 int cxDesired, int cyDesired, UINT fuLoad)
591{
592 HANDLE hRet = 0;
593
594 dprintf(("LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
595
596 if (fuLoad & LR_DEFAULTSIZE) {
597 if (uType == IMAGE_ICON) {
598 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXICON);
599 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYICON);
600 }
601 else if (uType == IMAGE_CURSOR) {
602 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR);
603 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYCURSOR);
604 }
605 }
606 if (fuLoad & LR_LOADFROMFILE) fuLoad &= ~LR_SHARED;
607
608 switch(uType) {
609 case IMAGE_BITMAP:
610 hRet = (HANDLE)LoadBitmapW(hinst, lpszName);
611 break;
612 case IMAGE_CURSOR:
613 hRet = (HANDLE)LoadCursorW(hinst, lpszName, cxDesired, cyDesired, fuLoad);
614 break;
615 case IMAGE_ICON:
616 hRet = (HANDLE)LoadIconW(hinst, lpszName, cxDesired, cyDesired, fuLoad);
617 break;
618 default:
619 dprintf(("LoadImageW: unsupported type %d!!", uType));
620 return 0;
621 }
622 dprintf(("LoadImageW returned %x\n", (int)hRet));
623
624 return(hRet);
625}
626/******************************************************************************
627 * CopyImage32 [USER32.61] Creates new image and copies attributes to it
628 *
629 * PARAMS
630 * hnd [I] Handle to image to copy
631 * type [I] Type of image to copy
632 * desiredx [I] Desired width of new image
633 * desiredy [I] Desired height of new image
634 * flags [I] Copy flags
635 *
636 * RETURNS
637 * Success: Handle to newly created image
638 * Failure: NULL
639 *
640 * FIXME: implementation still lacks nearly all features, see LR_*
641 * defines in windows.h
642 *
643 */
644HICON WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
645 INT desiredy, UINT flags )
646{
647 dprintf(("CopyImage %x %d (%d,%d) %x", hnd, type, desiredx, desiredy, flags));
648 switch (type)
649 {
650// case IMAGE_BITMAP:
651// return BITMAP_CopyBitmap(hnd);
652 case IMAGE_ICON:
653 return CopyIcon(hnd);
654 case IMAGE_CURSOR:
655 return CopyCursor(hnd);
656// return CopyCursorIcon(hnd,type, desiredx, desiredy, flags);
657 default:
658 dprintf(("CopyImage: Unsupported type"));
659 }
660 return 0;
661}
662//******************************************************************************
663//******************************************************************************
Note: See TracBrowser for help on using the repository browser.