Changeset 4573 for trunk/src/user32/loadres.cpp
- Timestamp:
- Nov 9, 2000, 7:15:23 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/loadres.cpp
r4558 r4573 1 /* $Id: loadres.cpp,v 1.3 2 2000-11-05 18:49:07sandervl Exp $ */1 /* $Id: loadres.cpp,v 1.33 2000-11-09 18:15:18 sandervl Exp $ */ 2 2 3 3 /* … … 107 107 //****************************************************************************** 108 108 //****************************************************************************** 109 HICON 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); 109 HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon) 110 { 111 if(HIWORD(lpszIcon)) { 112 dprintf(("LoadIconA %x %s", hinst, lpszIcon)); 113 } 114 else dprintf(("LoadIconA %x %x", hinst, lpszIcon)); 115 return LoadImageA(hinst, lpszIcon, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE); 116 } 117 //****************************************************************************** 118 //****************************************************************************** 119 HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon) 120 { 121 dprintf(("LoadIconA %x %x", hinst, lpszIcon)); 122 return LoadImageW(hinst, lpszIcon, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE); 123 } 124 //****************************************************************************** 125 //****************************************************************************** 126 HCURSOR LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor, DWORD cxDesired, 127 DWORD cyDesired, DWORD fuLoad) 128 { 129 HCURSOR hCursor; 130 HANDLE hMapping = 0; 131 char *ptr = NULL; 132 HRSRC hRes; 133 LPSTR restype = RT_CURSORA; 134 LPVOID lpOS2Resdata = NULL; 135 136 if(fuLoad & LR_LOADFROMFILE) 137 { 138 hMapping = VIRTUAL_MapFileW( lpszCursor, (LPVOID *)&ptr, TRUE); 139 if(hMapping == INVALID_HANDLE_VALUE) 140 return 0; 141 142 lpOS2Resdata = ConvertCursorToOS2(ptr); 143 hCursor = OSLibWinCreatePointer(lpOS2Resdata, cxDesired, cyDesired); 144 FreeOS2Resource(lpOS2Resdata); 145 146 UnmapViewOfFile(ptr); 147 CloseHandle(hMapping); 127 148 } 128 149 else 129 150 { 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 //****************************************************************************** 162 HICON 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 //****************************************************************************** 213 HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon) 214 { 215 return LoadIconA(hinst, lpszIcon, 0, 0, 0); 216 } 217 //****************************************************************************** 218 //****************************************************************************** 219 HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon) 220 { 221 return LoadIconW(hinst, lpszIcon, 0, 0, 0); 222 } 223 //****************************************************************************** 224 //****************************************************************************** 225 HCURSOR 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)); 151 if(!hinst) 152 { 153 hRes = FindResourceW(hInstanceUser32,lpszCursor,RT_CURSORW); 154 if(!hRes) { 155 hRes = FindResourceW(hInstanceUser32,lpszCursor,RT_GROUP_CURSORW); 156 restype = RT_GROUP_CURSORA; 157 } 158 if(hRes) 159 { 160 lpOS2Resdata = ConvertResourceToOS2(hInstanceUser32, restype, hRes); 161 hCursor = OSLibWinCreatePointer(lpOS2Resdata, cxDesired, cyDesired); 162 FreeOS2Resource(lpOS2Resdata); 163 } 164 else hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor, cxDesired, cyDesired); 165 } 166 else 167 { //not a system icon 168 hRes = FindResourceW(hinst,lpszCursor,RT_CURSORW); 169 if(!hRes) { 170 hRes = FindResourceW(hinst,lpszCursor,RT_GROUP_CURSORW); 171 restype = RT_GROUP_CURSORA; 172 } 173 if(hRes) { 174 lpOS2Resdata = ConvertResourceToOS2(hinst, restype, hRes); 175 hCursor = OSLibWinCreatePointer(lpOS2Resdata, cxDesired, cyDesired); 176 FreeOS2Resource(lpOS2Resdata); 177 } 178 else hCursor = 0; 179 } 180 } 181 dprintf(("LoadCursorA %x from %x returned %x\n", lpszCursor, hinst, hCursor)); 274 182 275 183 return(hCursor); … … 277 185 //****************************************************************************** 278 186 //****************************************************************************** 279 HCURSOR 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 else297 {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 else312 { //not a system icon313 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 //******************************************************************************330 187 HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor) 331 188 { 332 return LoadCursorA(hinst, lpszCursor, 0, 0, 0); 189 return LoadImageA(hinst, lpszCursor, IMAGE_CURSOR, 0, 0, 190 LR_SHARED | LR_DEFAULTSIZE ); 333 191 } 334 192 //****************************************************************************** … … 336 194 HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor) 337 195 { 338 return LoadCursorW(hinst, lpszCursor, 0, 0, 0); 339 } 340 //****************************************************************************** 341 //****************************************************************************** 342 BOOL 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 //****************************************************************************** 394 HANDLE LoadBitmapA(HINSTANCE hinst, LPCSTR lpszName, int cxDesired, int cyDesired, 196 return LoadImageW(hinst, lpszCursor, IMAGE_CURSOR, 0, 0, 197 LR_SHARED | LR_DEFAULTSIZE ); 198 } 199 /*********************************************************************** 200 * LoadCursorFromFileW (USER32.361) 201 */ 202 HCURSOR WIN32API LoadCursorFromFileW (LPCWSTR name) 203 { 204 return LoadImageW(0, name, IMAGE_CURSOR, 0, 0, 205 LR_LOADFROMFILE | LR_DEFAULTSIZE ); 206 } 207 /*********************************************************************** 208 * LoadCursorFromFileA (USER32.360) 209 */ 210 HCURSOR WIN32API LoadCursorFromFileA (LPCSTR name) 211 { 212 return LoadImageA(0, name, IMAGE_CURSOR, 0, 0, 213 LR_LOADFROMFILE | LR_DEFAULTSIZE ); 214 } 215 //****************************************************************************** 216 //NOTE: LR_CREATEDIBSECTION flag doesn't work (crash in GDI32)! (still??) 217 //****************************************************************************** 218 HANDLE LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszName, int cxDesired, int cyDesired, 395 219 UINT fuLoad) 396 220 { … … 404 228 int size; 405 229 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; 230 if (!(fuLoad & LR_LOADFROMFILE)) 231 { 232 handle = 0; 233 if(!hinst) 234 { 235 hRsrc = FindResourceW( hInstanceUser32, lpszName, RT_BITMAPW ); 236 if(hRsrc) { 237 handle = LoadResource( hInstanceUser32, hRsrc ); 238 } 239 } 240 if(handle == 0) 241 { 242 if (!(hRsrc = FindResourceW( hinst, lpszName, RT_BITMAPW ))) return 0; 243 if (!(handle = LoadResource( hinst, hRsrc ))) return 0; 244 } 245 246 if ((info = (BITMAPINFO *)LockResource( handle )) == NULL) return 0; 411 247 } 412 248 else 413 249 { 414 hMapping = VIRTUAL_MapFile A( lpszName, (LPVOID *)&ptr, TRUE);250 hMapping = VIRTUAL_MapFileW( lpszName, (LPVOID *)&ptr, TRUE); 415 251 if (hMapping == INVALID_HANDLE_VALUE) { 416 417 dprintf(("LoadBitmapA: failed to load file %s(lasterr=%x)", lpszName, GetLastError()));418 419 252 //TODO: last err set to ERROR_OPEN_FAILED if file not found; correct?? 253 dprintf(("LoadBitmapW: failed to load file %x (lasterr=%x)", lpszName, GetLastError())); 254 return 0; 255 } 420 256 info = (BITMAPINFO *)(ptr + sizeof(BITMAPFILEHEADER)); 421 257 } … … 482 318 hbitmap = CreateDIBitmap(hdc, &fix_info->bmiHeader, CBM_INIT, 483 319 bits, fix_info, DIB_RGB_COLORS ); 484 485 dprintf(("LoadBitmapA: CreateDIBitmap failed!!"));486 320 if(hbitmap == 0) { 321 dprintf(("LoadBitmapW: CreateDIBitmap failed!!")); 322 } 487 323 // } 488 324 } … … 492 328 GlobalFree(hFix); 493 329 } 494 if (fuLoad & LR_LOADFROMFILE) CloseHandle( hMapping ); 330 if(fuLoad & LR_LOADFROMFILE) { 331 UnmapViewOfFile(ptr); 332 CloseHandle(hMapping); 333 } 495 334 return hbitmap; 496 335 } 497 336 //****************************************************************************** 337 //TODO: scale bitmap 338 //****************************************************************************** 339 HANDLE CopyBitmap(HANDLE hBitmap, DWORD desiredx, DWORD desiredy) 340 { 341 HBITMAP res = 0; 342 BITMAP bm; 343 344 if(GetObjectA(hBitmap, sizeof(BITMAP), &bm) == FALSE) { 345 dprintf(("CopyBitmap: GetObject failed!!")); 346 return 0; 347 } 348 349 bm.bmBits = NULL; 350 res = CreateBitmapIndirect(&bm); 351 352 if(res) 353 { 354 char *buf = (char *)HeapAlloc( GetProcessHeap(), 0, bm.bmWidthBytes * 355 bm.bmHeight ); 356 GetBitmapBits (hBitmap, bm.bmWidthBytes * bm.bmHeight, buf); 357 SetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf); 358 HeapFree( GetProcessHeap(), 0, buf ); 359 } 360 return res; 361 } 362 //****************************************************************************** 498 363 //TODO: No support for RT_NEWBITMAP 499 364 //****************************************************************************** … … 502 367 HBITMAP hBitmap = 0; 503 368 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); 369 hBitmap = LoadImageA(hinst, lpszBitmap, IMAGE_BITMAP, 0, 0, 0); 513 370 514 371 if(HIWORD(lpszBitmap)) { 515 372 dprintf(("LoadBitmapA %x %s returned %08xh\n", hinst, lpszBitmap, hBitmap)); 516 373 } 517 374 else dprintf(("LoadBitmapA %x %x returned %08xh\n", hinst, lpszBitmap, hBitmap)); … … 526 383 HBITMAP hBitmap = 0; 527 384 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); 385 hBitmap = LoadBitmapW((hinst == 0) ? hInstanceUser32:hinst, lpszBitmap, 0, 0, 0); 535 386 536 387 if(HIWORD(lpszBitmap)) { 537 388 dprintf(("LoadBitmapW %x %s returned %08xh\n", hinst, lpszBitmap, hBitmap)); 538 389 } 539 390 else dprintf(("LoadBitmapW %x %x returned %08xh\n", hinst, lpszBitmap, hBitmap)); … … 542 393 } 543 394 //****************************************************************************** 544 //TODO: Far from complete, but works for loading resources from exe545 //fuLoad flag ignored546 395 //****************************************************************************** 547 396 HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType, 548 397 int cxDesired, int cyDesired, UINT fuLoad) 549 398 { 399 HANDLE res = 0; 400 LPCWSTR u_name; 401 402 if(HIWORD(lpszName)) { 403 dprintf(("LoadImageA %x %s %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); 404 } 405 else dprintf(("LoadImageA %x %x %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); 406 407 if (HIWORD(lpszName)) { 408 u_name = HEAP_strdupAtoW(GetProcessHeap(), 0, lpszName); 409 } 410 else u_name=(LPWSTR)lpszName; 411 412 res = LoadImageW(hinst, u_name, uType, cxDesired, cyDesired, fuLoad); 413 414 if (HIWORD(lpszName)) 415 HeapFree(GetProcessHeap(), 0, (LPVOID)u_name); 416 417 return res; 418 } 419 //****************************************************************************** 420 //****************************************************************************** 421 HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType, 422 int cxDesired, int cyDesired, UINT fuLoad) 423 { 550 424 HANDLE hRet = 0; 551 425 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 //****************************************************************************** 589 HANDLE 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)); 426 dprintf(("LoadImageW %x %x %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); 595 427 596 428 if (fuLoad & LR_DEFAULTSIZE) { … … 606 438 if (fuLoad & LR_LOADFROMFILE) fuLoad &= ~LR_SHARED; 607 439 608 switch(uType) { 440 switch (uType) 441 { 609 442 case IMAGE_BITMAP: 610 hRet = (HANDLE)LoadBitmapW(hinst, lpszName); 611 break; 443 { 444 hRet = (HANDLE)LoadBitmapW(hinst, lpszName, cxDesired, cyDesired, fuLoad); 445 break; 446 } 447 case IMAGE_ICON: 448 { 449 HDC hdc = GetDC(0); 450 UINT palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL); 451 if (palEnts == 0) 452 palEnts = 256; 453 ReleaseDC(0, hdc); 454 455 hRet = CURSORICON_Load(hinst, lpszName, cxDesired, cyDesired, palEnts, FALSE, fuLoad); 456 break; 457 } 458 612 459 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; 460 hRet = (HANDLE)LoadCursorW(hinst, lpszName, cxDesired, cyDesired, fuLoad); 461 break; 462 // return CURSORICON_Load(hinst, name, desiredx, desiredy, 1, TRUE, loadflags); 463 618 464 default: 619 465 dprintf(("LoadImageW: unsupported type %d!!", uType)); … … 642 488 * 643 489 */ 644 HICON WINAPI CopyImage( 645 490 HICON WINAPI CopyImage(HANDLE hnd, UINT type, INT desiredx, 491 INT desiredy, UINT flags ) 646 492 { 647 493 dprintf(("CopyImage %x %d (%d,%d) %x", hnd, type, desiredx, desiredy, flags)); 648 494 switch (type) 649 495 { 650 //case IMAGE_BITMAP:651 // return BITMAP_CopyBitmap(hnd);496 case IMAGE_BITMAP: 497 return CopyBitmap(hnd, desiredx, desiredy); 652 498 case IMAGE_ICON: 653 return CopyIcon(hnd);499 return (HANDLE)CURSORICON_ExtCopy(hnd, type, desiredx, desiredy, flags); 654 500 case IMAGE_CURSOR: 655 return CopyCursor(hnd); 501 /* Should call CURSORICON_ExtCopy but more testing 502 * needs to be done before we change this 503 */ 504 return O32_CopyCursor(hnd); 656 505 // return CopyCursorIcon(hnd,type, desiredx, desiredy, flags); 657 506 default:
Note:
See TracChangeset
for help on using the changeset viewer.