| 1 | /* $Id: loadres.cpp,v 1.10 1999-10-23 23:04:35 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): | 
|---|
| 9 | * | 
|---|
| 10 | * Copyright 1993 Alexandre Julliard | 
|---|
| 11 | *           1998 Huw D M Davies | 
|---|
| 12 | * | 
|---|
| 13 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 14 | * | 
|---|
| 15 | */ | 
|---|
| 16 | #include <os2win.h> | 
|---|
| 17 | #include <user32.h> | 
|---|
| 18 | #include <winres.h> | 
|---|
| 19 | #include <heapstring.h> | 
|---|
| 20 | #include <oslibres.h> | 
|---|
| 21 | #include <winconst.h> | 
|---|
| 22 | #include <win\virtual.h> | 
|---|
| 23 | #include "dib.h" | 
|---|
| 24 |  | 
|---|
| 25 | //****************************************************************************** | 
|---|
| 26 | //****************************************************************************** | 
|---|
| 27 | int WIN32API LoadStringA(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer) | 
|---|
| 28 | { | 
|---|
| 29 | Win32Resource *winres; | 
|---|
| 30 | LPWSTR  resstring; | 
|---|
| 31 | int     resstrlen = 0; | 
|---|
| 32 |  | 
|---|
| 33 | winres = (Win32Resource *)FindResourceA(hinst, (LPSTR)wID, RT_STRINGA); | 
|---|
| 34 | if(winres == NULL) { | 
|---|
| 35 | dprintf(("LoadStringA NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer)); | 
|---|
| 36 | *lpBuffer = 0; | 
|---|
| 37 | return 0; | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | resstring = (LPWSTR)winres->lockResource(); | 
|---|
| 41 | if(resstring) { | 
|---|
| 42 | resstrlen = min(lstrlenW(resstring)+1, cchBuffer); | 
|---|
| 43 | lstrcpynWtoA(lpBuffer, resstring, resstrlen); | 
|---|
| 44 | lpBuffer[resstrlen-1] = 0; | 
|---|
| 45 | resstrlen--; | 
|---|
| 46 | dprintf(("LoadStringA (%d) %s", resstrlen, lpBuffer)); | 
|---|
| 47 | } | 
|---|
| 48 | delete winres; | 
|---|
| 49 |  | 
|---|
| 50 | dprintf(("LoadStringA from %X, id %d buffersize %d\n", hinst, wID, cchBuffer)); | 
|---|
| 51 | return(resstrlen); | 
|---|
| 52 | } | 
|---|
| 53 | //****************************************************************************** | 
|---|
| 54 | //****************************************************************************** | 
|---|
| 55 | int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer) | 
|---|
| 56 | { | 
|---|
| 57 | Win32Resource *winres; | 
|---|
| 58 | LPWSTR resstring; | 
|---|
| 59 | int    resstrlen = 0; | 
|---|
| 60 |  | 
|---|
| 61 | winres = (Win32Resource *)FindResourceW(hinst, (LPWSTR)wID, RT_STRINGW); | 
|---|
| 62 | if(winres == NULL) { | 
|---|
| 63 | dprintf(("LoadStringW NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer)); | 
|---|
| 64 | *lpBuffer = 0; | 
|---|
| 65 | return 0; | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 | resstring = (LPWSTR)winres->lockResource(); | 
|---|
| 69 | if(resstring) { | 
|---|
| 70 | resstrlen = min(lstrlenW(resstring)+1, cchBuffer); | 
|---|
| 71 | lstrcpynW(lpBuffer, resstring, resstrlen); | 
|---|
| 72 | lpBuffer[resstrlen-1] = 0; | 
|---|
| 73 | resstrlen--; | 
|---|
| 74 | } | 
|---|
| 75 | delete winres; | 
|---|
| 76 |  | 
|---|
| 77 | dprintf(("LoadStringW from %X, id %d buffersize %d\n", hinst, wID, cchBuffer)); | 
|---|
| 78 | return(resstrlen); | 
|---|
| 79 | } | 
|---|
| 80 | //****************************************************************************** | 
|---|
| 81 | //****************************************************************************** | 
|---|
| 82 | HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon) | 
|---|
| 83 | { | 
|---|
| 84 | Win32Resource *winres; | 
|---|
| 85 | HICON          hIcon; | 
|---|
| 86 |  | 
|---|
| 87 | hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon); | 
|---|
| 88 | if(hIcon == 0) {//not a system icon | 
|---|
| 89 | winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_ICONA); | 
|---|
| 90 | if(winres == 0) { | 
|---|
| 91 | winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA); | 
|---|
| 92 | } | 
|---|
| 93 | if(winres) { | 
|---|
| 94 | hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); | 
|---|
| 95 | delete winres; | 
|---|
| 96 | } | 
|---|
| 97 | } | 
|---|
| 98 | dprintf(("LoadIconA (%X) returned %x\n", hinst, hIcon)); | 
|---|
| 99 |  | 
|---|
| 100 | return(hIcon); | 
|---|
| 101 | } | 
|---|
| 102 | //****************************************************************************** | 
|---|
| 103 | //****************************************************************************** | 
|---|
| 104 | HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon) | 
|---|
| 105 | { | 
|---|
| 106 | Win32Resource *winres; | 
|---|
| 107 | HICON          hIcon; | 
|---|
| 108 |  | 
|---|
| 109 | hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon); | 
|---|
| 110 | if(hIcon == 0) {//not a system icon | 
|---|
| 111 | winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_ICONW); | 
|---|
| 112 | if(winres == 0) { | 
|---|
| 113 | winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW); | 
|---|
| 114 | } | 
|---|
| 115 | if(winres) { | 
|---|
| 116 | hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); | 
|---|
| 117 | delete winres; | 
|---|
| 118 | } | 
|---|
| 119 | } | 
|---|
| 120 | dprintf(("LoadIconW (%X) returned %x\n", hinst, hIcon)); | 
|---|
| 121 |  | 
|---|
| 122 | return(hIcon); | 
|---|
| 123 | } | 
|---|
| 124 | //****************************************************************************** | 
|---|
| 125 | //****************************************************************************** | 
|---|
| 126 | HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor) | 
|---|
| 127 | { | 
|---|
| 128 | Win32Resource *winres; | 
|---|
| 129 | HCURSOR        hCursor; | 
|---|
| 130 |  | 
|---|
| 131 | hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor); | 
|---|
| 132 | if(hCursor == 0) {//not a system pointer | 
|---|
| 133 | winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_CURSORA); | 
|---|
| 134 | if(winres == 0) { | 
|---|
| 135 | winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_GROUP_CURSORA); | 
|---|
| 136 | } | 
|---|
| 137 | if(winres) { | 
|---|
| 138 | hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); | 
|---|
| 139 | delete winres; | 
|---|
| 140 | } | 
|---|
| 141 | } | 
|---|
| 142 | if(HIWORD(lpszCursor)) { | 
|---|
| 143 | dprintf(("LoadCursorA %s from %x returned %x\n", lpszCursor, hinst, hCursor)); | 
|---|
| 144 | } | 
|---|
| 145 | else dprintf(("LoadCursorA %x from %x returned %x\n", lpszCursor, hinst, hCursor)); | 
|---|
| 146 |  | 
|---|
| 147 | return(hCursor); | 
|---|
| 148 | } | 
|---|
| 149 | //****************************************************************************** | 
|---|
| 150 | //****************************************************************************** | 
|---|
| 151 | HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor) | 
|---|
| 152 | { | 
|---|
| 153 | Win32Resource *winres; | 
|---|
| 154 | HCURSOR        hCursor; | 
|---|
| 155 |  | 
|---|
| 156 | hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor); | 
|---|
| 157 | if(hCursor == 0) {//not a system pointer | 
|---|
| 158 | winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_CURSORW); | 
|---|
| 159 | if(winres == 0) { | 
|---|
| 160 | winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_GROUP_CURSORW); | 
|---|
| 161 | } | 
|---|
| 162 | if(winres) { | 
|---|
| 163 | hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); | 
|---|
| 164 | delete winres; | 
|---|
| 165 | } | 
|---|
| 166 | } | 
|---|
| 167 | dprintf(("LoadCursorW (%X) returned %x\n", hinst, hCursor)); | 
|---|
| 168 |  | 
|---|
| 169 | return(hCursor); | 
|---|
| 170 | } | 
|---|
| 171 | //****************************************************************************** | 
|---|
| 172 | //****************************************************************************** | 
|---|
| 173 | BOOL IsSystemBitmap(ULONG *id) | 
|---|
| 174 | { | 
|---|
| 175 | switch(*id) | 
|---|
| 176 | { | 
|---|
| 177 | case OBM_UPARROW_W: | 
|---|
| 178 | case OBM_DNARROW_W: | 
|---|
| 179 | case OBM_RGARROW_W: | 
|---|
| 180 | case OBM_LFARROW_W: | 
|---|
| 181 | case OBM_RESTORE_W: | 
|---|
| 182 | case OBM_RESTORED_W: | 
|---|
| 183 | case OBM_UPARROWD_W: | 
|---|
| 184 | case OBM_DNARROWD_W: | 
|---|
| 185 | case OBM_RGARROWD_W: | 
|---|
| 186 | case OBM_LFARROWD_W: | 
|---|
| 187 | case OBM_OLD_UPARROW_W: | 
|---|
| 188 | case OBM_OLD_DNARROW_W: | 
|---|
| 189 | case OBM_OLD_RGARROW_W: | 
|---|
| 190 | case OBM_OLD_LFARROW_W: | 
|---|
| 191 | case OBM_CHECK_W: | 
|---|
| 192 | case OBM_CHECKBOXES_W: | 
|---|
| 193 | case OBM_BTNCORNERS_W: | 
|---|
| 194 | case OBM_COMBO_W: | 
|---|
| 195 | case OBM_REDUCE_W: | 
|---|
| 196 | case OBM_REDUCED_W: | 
|---|
| 197 | case OBM_ZOOM_W: | 
|---|
| 198 | case OBM_ZOOMD_W: | 
|---|
| 199 | case OBM_SIZE_W: | 
|---|
| 200 | case OBM_CLOSE_W: | 
|---|
| 201 | case OBM_MNARROW_W: | 
|---|
| 202 | case OBM_UPARROWI_W: | 
|---|
| 203 | case OBM_DNARROWI_W: | 
|---|
| 204 | case OBM_RGARROWI_W: | 
|---|
| 205 | case OBM_LFARROWI_W: | 
|---|
| 206 | return TRUE; | 
|---|
| 207 |  | 
|---|
| 208 | //TODO: Not supported by Open32. Replacement may not be accurate | 
|---|
| 209 | case OBM_OLD_CLOSE_W: | 
|---|
| 210 | *id = OBM_CLOSE_W; | 
|---|
| 211 | return TRUE; | 
|---|
| 212 |  | 
|---|
| 213 | case OBM_BTSIZE_W: | 
|---|
| 214 | *id = OBM_SIZE_W; | 
|---|
| 215 | return TRUE; | 
|---|
| 216 |  | 
|---|
| 217 | case OBM_OLD_REDUCE_W: | 
|---|
| 218 | *id = OBM_REDUCE_W; | 
|---|
| 219 | return TRUE; | 
|---|
| 220 |  | 
|---|
| 221 | case OBM_OLD_ZOOM_W: | 
|---|
| 222 | *id = OBM_ZOOM_W; | 
|---|
| 223 | return TRUE; | 
|---|
| 224 |  | 
|---|
| 225 | case OBM_OLD_RESTORE_W: | 
|---|
| 226 | *id = OBM_RESTORE_W; | 
|---|
| 227 | return TRUE; | 
|---|
| 228 |  | 
|---|
| 229 | default: | 
|---|
| 230 | return FALSE; | 
|---|
| 231 | } | 
|---|
| 232 | } | 
|---|
| 233 | //****************************************************************************** | 
|---|
| 234 | //NOTE: LR_CREATEDIBSECTION flag doesn't work (crash in GDI32)! | 
|---|
| 235 | //****************************************************************************** | 
|---|
| 236 | HANDLE LoadBitmapA(HINSTANCE hinst, LPCSTR lpszName, int cxDesired, int cyDesired, | 
|---|
| 237 | UINT fuLoad) | 
|---|
| 238 | { | 
|---|
| 239 | HBITMAP hbitmap = 0; | 
|---|
| 240 | HDC hdc; | 
|---|
| 241 | HRSRC hRsrc; | 
|---|
| 242 | HGLOBAL handle, hMapping = 0; | 
|---|
| 243 | char *ptr = NULL; | 
|---|
| 244 | BITMAPINFO *info, *fix_info=NULL; | 
|---|
| 245 | HGLOBAL hFix; | 
|---|
| 246 | int size; | 
|---|
| 247 |  | 
|---|
| 248 | if (!(fuLoad & LR_LOADFROMFILE)) { | 
|---|
| 249 | if (!(hRsrc = FindResourceA( hinst, lpszName, RT_BITMAPA ))) return 0; | 
|---|
| 250 | if (!(handle = LoadResource( hinst, hRsrc ))) return 0; | 
|---|
| 251 |  | 
|---|
| 252 | if ((info = (BITMAPINFO *)LockResource( handle )) == NULL) return 0; | 
|---|
| 253 | } | 
|---|
| 254 | else | 
|---|
| 255 | { | 
|---|
| 256 | if (!(hMapping = VIRTUAL_MapFileA( lpszName, (LPVOID *)&ptr ))) return 0; | 
|---|
| 257 | info = (BITMAPINFO *)(ptr + sizeof(BITMAPFILEHEADER)); | 
|---|
| 258 | } | 
|---|
| 259 |  | 
|---|
| 260 | //TODO: This has to be removed once pe2lx stores win32 resources!!! | 
|---|
| 261 | if (info->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) && | 
|---|
| 262 | info->bmiHeader.biSize != sizeof(BITMAPINFOHEADER)) | 
|---|
| 263 | {//assume it contains a file header first | 
|---|
| 264 | info = (BITMAPINFO *)((char *)info + sizeof(BITMAPFILEHEADER)); | 
|---|
| 265 | } | 
|---|
| 266 |  | 
|---|
| 267 | if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { | 
|---|
| 268 | size = sizeof(BITMAPINFOHEADER) + | 
|---|
| 269 | (sizeof (RGBTRIPLE) << ((BITMAPCOREHEADER *)info)->bcBitCount); | 
|---|
| 270 | } else | 
|---|
| 271 | size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS); | 
|---|
| 272 |  | 
|---|
| 273 | if ((hFix = GlobalAlloc(0, size)) != NULL) fix_info = (BITMAPINFO *)GlobalLock(hFix); | 
|---|
| 274 | if (fix_info) { | 
|---|
| 275 | BYTE pix; | 
|---|
| 276 |  | 
|---|
| 277 | if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { | 
|---|
| 278 | ULONG colors; | 
|---|
| 279 | ULONG *p, *q; | 
|---|
| 280 |  | 
|---|
| 281 | memset (fix_info, 0, sizeof (BITMAPINFOHEADER)); | 
|---|
| 282 | fix_info->bmiHeader.biSize     = sizeof (BITMAPINFOHEADER); | 
|---|
| 283 | fix_info->bmiHeader.biWidth    = ((BITMAPCOREHEADER *)info)->bcWidth; | 
|---|
| 284 | fix_info->bmiHeader.biHeight   = ((BITMAPCOREHEADER *)info)->bcHeight; | 
|---|
| 285 | fix_info->bmiHeader.biPlanes   = ((BITMAPCOREHEADER *)info)->bcPlanes; | 
|---|
| 286 | fix_info->bmiHeader.biBitCount = ((BITMAPCOREHEADER *)info)->bcBitCount; | 
|---|
| 287 |  | 
|---|
| 288 | p = (PULONG)((char *)info + sizeof(BITMAPCOREHEADER)); | 
|---|
| 289 | q = (PULONG)((char *)fix_info + sizeof(BITMAPINFOHEADER)); | 
|---|
| 290 | for (colors = 1 << fix_info->bmiHeader.biBitCount; colors > 0; colors--) { | 
|---|
| 291 | *q = *p & 0x00FFFFFFUL; | 
|---|
| 292 | q++; | 
|---|
| 293 | p = (PULONG)((char *)p + sizeof (RGBTRIPLE)); | 
|---|
| 294 | } | 
|---|
| 295 | } else | 
|---|
| 296 | memcpy(fix_info, info, size); | 
|---|
| 297 |  | 
|---|
| 298 | size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS); | 
|---|
| 299 | pix = *((LPBYTE)info + size); | 
|---|
| 300 | DIB_FixColorsToLoadflags(fix_info, fuLoad, pix); | 
|---|
| 301 | if ((hdc = GetDC(0)) != 0) { | 
|---|
| 302 | char *bits = (char *)info + size; | 
|---|
| 303 | if (fuLoad & LR_CREATEDIBSECTION) { | 
|---|
| 304 | DIBSECTION dib; | 
|---|
| 305 | hbitmap = CreateDIBSection(hdc, fix_info, DIB_RGB_COLORS, NULL, 0, 0); | 
|---|
| 306 | GetObjectA(hbitmap, sizeof(DIBSECTION), &dib); | 
|---|
| 307 | SetDIBits(hdc, hbitmap, 0, dib.dsBm.bmHeight, bits, info, | 
|---|
| 308 | DIB_RGB_COLORS); | 
|---|
| 309 | } | 
|---|
| 310 | else { | 
|---|
| 311 | hbitmap = CreateDIBitmap( hdc, &fix_info->bmiHeader, CBM_INIT, | 
|---|
| 312 | bits, fix_info, DIB_RGB_COLORS ); | 
|---|
| 313 | } | 
|---|
| 314 | ReleaseDC( 0, hdc ); | 
|---|
| 315 | } | 
|---|
| 316 | GlobalUnlock(hFix); | 
|---|
| 317 | GlobalFree(hFix); | 
|---|
| 318 | } | 
|---|
| 319 | if (fuLoad & LR_LOADFROMFILE) CloseHandle( hMapping ); | 
|---|
| 320 | return hbitmap; | 
|---|
| 321 | } | 
|---|
| 322 | //****************************************************************************** | 
|---|
| 323 | //TODO: No support for RT_NEWBITMAP | 
|---|
| 324 | //****************************************************************************** | 
|---|
| 325 | HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap) | 
|---|
| 326 | { | 
|---|
| 327 | HBITMAP hBitmap = 0; | 
|---|
| 328 |  | 
|---|
| 329 | if(IsSystemBitmap((ULONG *)&lpszBitmap)) { | 
|---|
| 330 | hBitmap = O32_LoadBitmap(hinst, lpszBitmap); | 
|---|
| 331 | } | 
|---|
| 332 | if(!hBitmap) { | 
|---|
| 333 | hBitmap = LoadBitmapA(hinst, lpszBitmap, 0, 0, 0); | 
|---|
| 334 | } | 
|---|
| 335 | dprintf(("LoadBitmapA returned %08xh\n", hBitmap)); | 
|---|
| 336 |  | 
|---|
| 337 | return(hBitmap); | 
|---|
| 338 | } | 
|---|
| 339 | //****************************************************************************** | 
|---|
| 340 | //TODO: No support for RT_NEWBITMAP | 
|---|
| 341 | //****************************************************************************** | 
|---|
| 342 | HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap) | 
|---|
| 343 | { | 
|---|
| 344 | HBITMAP hBitmap; | 
|---|
| 345 |  | 
|---|
| 346 | if(IsSystemBitmap((ULONG *)&lpszBitmap)) { | 
|---|
| 347 | hBitmap = O32_LoadBitmap(hinst, (LPCSTR)lpszBitmap); | 
|---|
| 348 | } | 
|---|
| 349 | if(!hBitmap) { | 
|---|
| 350 | if(HIWORD(lpszBitmap) != 0) { | 
|---|
| 351 | lpszBitmap = (LPWSTR)UnicodeToAsciiString((LPWSTR)lpszBitmap); | 
|---|
| 352 | } | 
|---|
| 353 | hBitmap = LoadBitmapA(hinst, (LPSTR)lpszBitmap, 0, 0, 0); | 
|---|
| 354 | } | 
|---|
| 355 |  | 
|---|
| 356 | if(HIWORD(lpszBitmap) != 0) | 
|---|
| 357 | FreeAsciiString((LPSTR)lpszBitmap); | 
|---|
| 358 |  | 
|---|
| 359 | dprintf(("LoadBitmapW returned %08xh\n", hBitmap)); | 
|---|
| 360 |  | 
|---|
| 361 | return(hBitmap); | 
|---|
| 362 | } | 
|---|
| 363 | //****************************************************************************** | 
|---|
| 364 | //TODO: Far from complete, but works for loading resources from exe | 
|---|
| 365 | //fuLoad flag ignored | 
|---|
| 366 | //****************************************************************************** | 
|---|
| 367 | HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType, | 
|---|
| 368 | int cxDesired, int cyDesired, UINT fuLoad) | 
|---|
| 369 | { | 
|---|
| 370 | HANDLE hRet = 0; | 
|---|
| 371 |  | 
|---|
| 372 | if(HIWORD(lpszName)) { | 
|---|
| 373 | dprintf(("LoadImageA NOT COMPLETE %x %s %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); | 
|---|
| 374 | } | 
|---|
| 375 | else  dprintf(("LoadImageA NOT COMPLETE %x %x %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); | 
|---|
| 376 |  | 
|---|
| 377 | if (fuLoad & LR_DEFAULTSIZE) { | 
|---|
| 378 | if (uType == IMAGE_ICON) { | 
|---|
| 379 | if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXICON); | 
|---|
| 380 | if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYICON); | 
|---|
| 381 | } | 
|---|
| 382 | else if (uType == IMAGE_CURSOR) { | 
|---|
| 383 | if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR); | 
|---|
| 384 | if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYCURSOR); | 
|---|
| 385 | } | 
|---|
| 386 | } | 
|---|
| 387 | if (fuLoad & LR_LOADFROMFILE) fuLoad &= ~LR_SHARED; | 
|---|
| 388 |  | 
|---|
| 389 | switch(uType) { | 
|---|
| 390 | case IMAGE_BITMAP: | 
|---|
| 391 | hRet = (HANDLE)LoadBitmapA(hinst, lpszName, cxDesired, cyDesired, fuLoad); | 
|---|
| 392 | break; | 
|---|
| 393 | case IMAGE_CURSOR: | 
|---|
| 394 | hRet = (HANDLE)LoadCursorA(hinst, lpszName); | 
|---|
| 395 | break; | 
|---|
| 396 | case IMAGE_ICON: | 
|---|
| 397 | hRet = (HANDLE)LoadIconA(hinst, lpszName); | 
|---|
| 398 | break; | 
|---|
| 399 | default: | 
|---|
| 400 | dprintf(("LoadImageA: unsupported type %d!!", uType)); | 
|---|
| 401 | return 0; | 
|---|
| 402 | } | 
|---|
| 403 | dprintf(("LoadImageA returned %d\n", (int)hRet)); | 
|---|
| 404 |  | 
|---|
| 405 | return(hRet); | 
|---|
| 406 | } | 
|---|
| 407 | //****************************************************************************** | 
|---|
| 408 | //****************************************************************************** | 
|---|
| 409 | HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType, | 
|---|
| 410 | int cxDesired, int cyDesired, UINT fuLoad) | 
|---|
| 411 | { | 
|---|
| 412 | HANDLE hRet = 0; | 
|---|
| 413 |  | 
|---|
| 414 | dprintf(("LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired)); | 
|---|
| 415 |  | 
|---|
| 416 | if (fuLoad & LR_DEFAULTSIZE) { | 
|---|
| 417 | if (uType == IMAGE_ICON) { | 
|---|
| 418 | if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXICON); | 
|---|
| 419 | if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYICON); | 
|---|
| 420 | } | 
|---|
| 421 | else if (uType == IMAGE_CURSOR) { | 
|---|
| 422 | if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR); | 
|---|
| 423 | if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYCURSOR); | 
|---|
| 424 | } | 
|---|
| 425 | } | 
|---|
| 426 | if (fuLoad & LR_LOADFROMFILE) fuLoad &= ~LR_SHARED; | 
|---|
| 427 |  | 
|---|
| 428 | switch(uType) { | 
|---|
| 429 | case IMAGE_BITMAP: | 
|---|
| 430 | hRet = (HANDLE)LoadBitmapW(hinst, lpszName); | 
|---|
| 431 | break; | 
|---|
| 432 | case IMAGE_CURSOR: | 
|---|
| 433 | hRet = (HANDLE)LoadCursorW(hinst, lpszName); | 
|---|
| 434 | break; | 
|---|
| 435 | case IMAGE_ICON: | 
|---|
| 436 | hRet = (HANDLE)LoadIconW(hinst, lpszName); | 
|---|
| 437 | break; | 
|---|
| 438 | default: | 
|---|
| 439 | dprintf(("LoadImageW: unsupported type %d!!", uType)); | 
|---|
| 440 | return 0; | 
|---|
| 441 | } | 
|---|
| 442 | dprintf(("LoadImageW returned %d\n", (int)hRet)); | 
|---|
| 443 |  | 
|---|
| 444 | return(hRet); | 
|---|
| 445 | } | 
|---|
| 446 | /****************************************************************************** | 
|---|
| 447 | * CopyImage32 [USER32.61]  Creates new image and copies attributes to it | 
|---|
| 448 | * | 
|---|
| 449 | * PARAMS | 
|---|
| 450 | *    hnd      [I] Handle to image to copy | 
|---|
| 451 | *    type     [I] Type of image to copy | 
|---|
| 452 | *    desiredx [I] Desired width of new image | 
|---|
| 453 | *    desiredy [I] Desired height of new image | 
|---|
| 454 | *    flags    [I] Copy flags | 
|---|
| 455 | * | 
|---|
| 456 | * RETURNS | 
|---|
| 457 | *    Success: Handle to newly created image | 
|---|
| 458 | *    Failure: NULL | 
|---|
| 459 | * | 
|---|
| 460 | * FIXME: implementation still lacks nearly all features, see LR_* | 
|---|
| 461 | * defines in windows.h | 
|---|
| 462 | * | 
|---|
| 463 | */ | 
|---|
| 464 | HICON WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, | 
|---|
| 465 | INT desiredy, UINT flags ) | 
|---|
| 466 | { | 
|---|
| 467 | dprintf(("CopyImage %x %d (%d,%d) %x", hnd, type, desiredx, desiredy, flags)); | 
|---|
| 468 | switch (type) | 
|---|
| 469 | { | 
|---|
| 470 | //      case IMAGE_BITMAP: | 
|---|
| 471 | //              return BITMAP_CopyBitmap(hnd); | 
|---|
| 472 | case IMAGE_ICON: | 
|---|
| 473 | return CopyIcon(hnd); | 
|---|
| 474 | case IMAGE_CURSOR: | 
|---|
| 475 | return CopyCursor(hnd); | 
|---|
| 476 | default: | 
|---|
| 477 | dprintf(("CopyImage: Unsupported type")); | 
|---|
| 478 | } | 
|---|
| 479 | return 0; | 
|---|
| 480 | } | 
|---|
| 481 | //****************************************************************************** | 
|---|
| 482 | //****************************************************************************** | 
|---|