Changeset 1667 for trunk/src/user32/loadres.cpp
- Timestamp:
- Nov 9, 1999, 6:07:23 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/loadres.cpp
r1612 r1667 1 /* $Id: loadres.cpp,v 1.1 4 1999-11-05 12:54:10 sandervlExp $ */1 /* $Id: loadres.cpp,v 1.15 1999-11-09 17:07:21 cbratschi Exp $ */ 2 2 3 3 /* … … 23 23 #include <win\virtual.h> 24 24 #include "dib.h" 25 #include "initterm.h" 25 26 26 27 //****************************************************************************** … … 33 34 34 35 if (buffer && buflen) 35 36 buffer2 = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, buflen * 2 ); 36 37 37 38 retval = LoadStringW(instance,resource_id,buffer2,buflen); … … 39 40 if (buffer2) 40 41 { 41 42 43 44 45 46 47 42 if (retval) { 43 lstrcpynWtoA( buffer, buffer2, buflen ); 44 retval = lstrlenA( buffer ); 45 } 46 else 47 *buffer = 0; 48 HeapFree( GetProcessHeap(), 0, buffer2 ); 48 49 } 49 50 return retval; … … 58 59 int i = 0; 59 60 60 /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out 61 /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out 61 62 * 20 - 31. */ 62 63 winres = (Win32Resource *)FindResourceW(hinst, (LPWSTR)(((wID>>4)&0xffff)+1), RT_STRINGW); … … 69 70 p = (LPWSTR)winres->lockResource(); 70 71 if(p) { 71 72 73 74 75 76 77 78 79 80 }81 82 83 84 85 86 72 string_num = wID & 0x000f; 73 for (i = 0; i < string_num; i++) 74 p += *p + 1; 75 76 if (lpBuffer == NULL) return *p; 77 i = min(cchBuffer - 1, *p); 78 if (i > 0) { 79 memcpy(lpBuffer, p + 1, i * sizeof (WCHAR)); 80 lpBuffer[i] = (WCHAR) 0; 81 } 82 else { 83 if (cchBuffer > 1) { 84 lpBuffer[0] = (WCHAR) 0; 85 return 0; 86 } 87 } 87 88 } 88 89 delete winres; … … 98 99 HICON hIcon; 99 100 100 hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon); 101 if(hIcon == 0) {//not a system icon 101 if (!hinst) 102 { 103 winres = (Win32Resource*)FindResourceA(hInstanceUser32,lpszIcon,RT_ICONA); 104 if (!winres) winres = (Win32Resource*)FindResourceA(hInstanceUser32,lpszIcon,RT_GROUP_ICONA); 105 if (winres) 106 { 107 hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); 108 delete winres; 109 } else hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON)); 110 } else 111 { //not a system icon 102 112 winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_ICONA); 103 113 if(winres == 0) { … … 107 117 hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); 108 118 delete winres; 109 } 119 } else hIcon = 0; 110 120 } 111 121 dprintf(("LoadIconA (%X) returned %x\n", hinst, hIcon)); … … 120 130 HICON hIcon; 121 131 122 hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon); 123 if(hIcon == 0) {//not a system icon 132 if (!hinst) 133 { 134 winres = (Win32Resource*)FindResourceW(hInstanceUser32,lpszIcon,RT_ICONW); 135 if (!winres) winres = (Win32Resource*)FindResourceW(hInstanceUser32,lpszIcon,RT_GROUP_ICONW); 136 if (winres) 137 { 138 hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); 139 delete winres; 140 } else hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON)); 141 } else 142 {//not a system icon 124 143 winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_ICONW); 125 144 if(winres == 0) { … … 129 148 hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); 130 149 delete winres; 131 } 150 } else hIcon = 0; 132 151 } 133 152 dprintf(("LoadIconW (%X) returned %x\n", hinst, hIcon)); … … 142 161 HCURSOR hCursor; 143 162 144 hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor); 145 if(hCursor == 0) {//not a system pointer 163 if (!hinst) 164 { 165 winres = (Win32Resource*)FindResourceA(hInstanceUser32,lpszCursor,RT_CURSORA); 166 if (!winres) winres = (Win32Resource*)FindResourceA(hInstanceUser32,lpszCursor,RT_GROUP_CURSORA); 167 if (winres) 168 { 169 hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); 170 delete winres; 171 } else hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor,GetSystemMetrics(SM_CXCURSOR),GetSystemMetrics(SM_CYCURSOR)); 172 } else 173 {//not a system pointer 146 174 winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_CURSORA); 147 175 if(winres == 0) { … … 151 179 hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); 152 180 delete winres; 153 } 181 } else hCursor = 0; 154 182 } 155 183 if(HIWORD(lpszCursor)) { … … 167 195 HCURSOR hCursor; 168 196 169 hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor); 170 if(hCursor == 0) {//not a system pointer 197 if (!hinst) 198 { 199 winres = (Win32Resource*)FindResourceW(hInstanceUser32,lpszCursor,RT_CURSORW); 200 if (!winres) winres = (Win32Resource*)FindResourceW(hInstanceUser32,lpszCursor,RT_GROUP_CURSORW); 201 if (winres) 202 { 203 hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); 204 delete winres; 205 } else hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor,GetSystemMetrics(SM_CXCURSOR),GetSystemMetrics(SM_CYCURSOR)); 206 } else 207 {//not a system pointer 171 208 winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_CURSORW); 172 209 if(winres == 0) { … … 176 213 hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); 177 214 delete winres; 178 } 215 } else hCursor = 0; 179 216 } 180 217 dprintf(("LoadCursorW (%X) returned %x\n", hinst, hCursor)); … … 341 378 HBITMAP hBitmap = 0; 342 379 343 if(IsSystemBitmap((ULONG *)&lpszBitmap)) { 344 hBitmap = O32_LoadBitmap(hinst, lpszBitmap); 380 if (!hinst) 381 { 382 if(IsSystemBitmap((ULONG *)&lpszBitmap)) 383 { 384 hBitmap = O32_LoadBitmap(hInstanceUser32,lpszBitmap); 385 if (!hBitmap) hBitmap = O32_LoadBitmap(hinst,lpszBitmap); 386 } else hBitmap = 0; 387 } else hBitmap = LoadBitmapA(hinst, lpszBitmap, 0, 0, 0); 388 dprintf(("LoadBitmapA returned %08xh\n", hBitmap)); 389 390 return(hBitmap); 391 } 392 //****************************************************************************** 393 //TODO: No support for RT_NEWBITMAP 394 //****************************************************************************** 395 HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap) 396 { 397 HBITMAP hBitmap = 0; 398 399 if (!hinst) 400 { 401 if(IsSystemBitmap((ULONG *)&lpszBitmap)) 402 { 403 hBitmap = O32_LoadBitmap(hInstanceUser32,(LPCSTR)lpszBitmap); 404 if (!hBitmap) hBitmap = O32_LoadBitmap(hinst,(LPCSTR)lpszBitmap); 405 } else hBitmap = 0; 406 } else 407 { 408 if(HIWORD(lpszBitmap) != 0) 409 lpszBitmap = (LPWSTR)UnicodeToAsciiString((LPWSTR)lpszBitmap); 410 411 hBitmap = LoadBitmapA(hinst, (LPSTR)lpszBitmap, 0, 0, 0); 412 413 if(HIWORD(lpszBitmap) != 0) 414 FreeAsciiString((LPSTR)lpszBitmap); 345 415 } 346 if(!hBitmap) {347 hBitmap = LoadBitmapA(hinst, lpszBitmap, 0, 0, 0);348 }349 dprintf(("LoadBitmapA returned %08xh\n", hBitmap));350 351 return(hBitmap);352 }353 //******************************************************************************354 //TODO: No support for RT_NEWBITMAP355 //******************************************************************************356 HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)357 {358 HBITMAP hBitmap = 0;359 360 if(IsSystemBitmap((ULONG *)&lpszBitmap)) {361 hBitmap = O32_LoadBitmap(hinst, (LPCSTR)lpszBitmap);362 }363 if(!hBitmap) {364 if(HIWORD(lpszBitmap) != 0) {365 lpszBitmap = (LPWSTR)UnicodeToAsciiString((LPWSTR)lpszBitmap);366 }367 hBitmap = LoadBitmapA(hinst, (LPSTR)lpszBitmap, 0, 0, 0);368 }369 370 if(HIWORD(lpszBitmap) != 0)371 FreeAsciiString((LPSTR)lpszBitmap);372 416 373 417 dprintf(("LoadBitmapW returned %08xh\n", hBitmap)); … … 385 429 386 430 if(HIWORD(lpszName)) { 387 431 dprintf(("LoadImageA NOT COMPLETE %x %s %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); 388 432 } 389 else 433 else dprintf(("LoadImageA NOT COMPLETE %x %x %d (%d,%d)\n", hinst, lpszName, uType, cxDesired, cyDesired)); 390 434 391 435 if (fuLoad & LR_DEFAULTSIZE) { … … 482 526 switch (type) 483 527 { 484 // 485 // 486 487 488 489 490 491 528 // case IMAGE_BITMAP: 529 // return BITMAP_CopyBitmap(hnd); 530 case IMAGE_ICON: 531 return CopyIcon(hnd); 532 case IMAGE_CURSOR: 533 return CopyCursor(hnd); 534 default: 535 dprintf(("CopyImage: Unsupported type")); 492 536 } 493 537 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.