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

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

missing OBM_TNTYPE + fix for messages sent to windows after they received WM_DESTROY & WM_NCDESTORY

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