- Timestamp:
- Aug 22, 1999, 6:46:58 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/user32/new/loadres.cpp (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/loadres.cpp
r618 r627 1 /* $Id: loadres.cpp,v 1. 9 1999-08-22 11:10:34 sandervlExp $ */1 /* $Id: loadres.cpp,v 1.10 1999-08-22 16:46:58 dengert Exp $ */ 2 2 3 3 /* … … 9 9 * 10 10 * Copyright 1993 Alexandre Julliard 11 * 1998 Huw D M Davies11 * 1998 Huw D M Davies 12 12 * 13 13 * Project Odin Software License can be found in LICENSE.TXT … … 29 29 Win32Resource *winres; 30 30 LPWSTR resstring; 31 int resstrlen = 0;31 int resstrlen = 0; 32 32 33 33 winres = (Win32Resource *)FindResourceA(hinst, (LPSTR)wID, RT_STRINGA); … … 36 36 return 0; 37 37 } 38 38 39 39 resstring = (LPWSTR)winres->lockResource(); 40 40 if(resstring) { … … 56 56 Win32Resource *winres; 57 57 LPWSTR resstring; 58 int resstrlen = 0;58 int resstrlen = 0; 59 59 60 60 winres = (Win32Resource *)FindResourceW(hinst, (LPWSTR)wID, RT_STRINGW); … … 63 63 return 0; 64 64 } 65 65 66 66 resstring = (LPWSTR)winres->lockResource(); 67 67 if(resstring) { … … 81 81 { 82 82 Win32Resource *winres; 83 HICON hIcon;83 HICON hIcon; 84 84 85 85 hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon); 86 86 if(hIcon == 0) {//not a system icon 87 winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_ICONA);88 if(winres == 0) {89 winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA);90 }91 if(winres) {87 winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_ICONA); 88 if(winres == 0) { 89 winres = (Win32Resource *)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA); 90 } 91 if(winres) { 92 92 hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); 93 93 delete winres; 94 }94 } 95 95 } 96 96 dprintf(("LoadIconA (%X) returned %x\n", hinst, hIcon)); … … 103 103 { 104 104 Win32Resource *winres; 105 HICON hIcon;105 HICON hIcon; 106 106 107 107 hIcon = OSLibWinQuerySysIcon((ULONG)lpszIcon); 108 108 if(hIcon == 0) {//not a system icon 109 winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_ICONW);110 if(winres == 0) {111 winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW);112 }113 if(winres) {109 winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_ICONW); 110 if(winres == 0) { 111 winres = (Win32Resource *)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW); 112 } 113 if(winres) { 114 114 hIcon = OSLibWinCreateIcon(winres->lockOS2Resource()); 115 115 delete winres; 116 }116 } 117 117 } 118 118 dprintf(("LoadIconW (%X) returned %x\n", hinst, hIcon)); … … 125 125 { 126 126 Win32Resource *winres; 127 HCURSOR hCursor;127 HCURSOR hCursor; 128 128 129 129 hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor); 130 130 if(hCursor == 0) {//not a system pointer 131 winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_CURSORA);132 if(winres == 0) {133 winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_GROUP_CURSORA);134 }135 if(winres) {131 winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_CURSORA); 132 if(winres == 0) { 133 winres = (Win32Resource *)FindResourceA(hinst, lpszCursor, RT_GROUP_CURSORA); 134 } 135 if(winres) { 136 136 hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); 137 137 delete winres; 138 }138 } 139 139 } 140 140 dprintf(("LoadCursorA (%X) returned %x\n", hinst, hCursor)); … … 147 147 { 148 148 Win32Resource *winres; 149 HCURSOR hCursor;149 HCURSOR hCursor; 150 150 151 151 hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor); 152 152 if(hCursor == 0) {//not a system pointer 153 winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_CURSORW);154 if(winres == 0) {155 winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_GROUP_CURSORW);156 }157 if(winres) {153 winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_CURSORW); 154 if(winres == 0) { 155 winres = (Win32Resource *)FindResourceW(hinst, lpszCursor, RT_GROUP_CURSORW); 156 } 157 if(winres) { 158 158 hCursor = OSLibWinCreatePointer(winres->lockOS2Resource()); 159 159 delete winres; 160 }160 } 161 161 } 162 162 dprintf(("LoadCursorW (%X) returned %x\n", hinst, hCursor)); … … 170 170 switch(*id) 171 171 { 172 case OBM_UPARROW_W:173 case OBM_DNARROW_W:174 case OBM_RGARROW_W:175 case OBM_LFARROW_W:176 case OBM_RESTORE_W:177 case OBM_RESTORED_W:178 case OBM_UPARROWD_W:179 case OBM_DNARROWD_W:180 case OBM_RGARROWD_W:181 case OBM_LFARROWD_W:182 case OBM_OLD_UPARROW_W:183 case OBM_OLD_DNARROW_W:184 case OBM_OLD_RGARROW_W:185 case OBM_OLD_LFARROW_W:186 case OBM_CHECK_W:187 case OBM_CHECKBOXES_W:188 case OBM_BTNCORNERS_W:189 case OBM_COMBO_W:190 case OBM_REDUCE_W:191 case OBM_REDUCED_W:192 case OBM_ZOOM_W:193 case OBM_ZOOMD_W:194 case OBM_SIZE_W:195 case OBM_CLOSE_W:196 case OBM_MNARROW_W:197 case OBM_UPARROWI_W:198 case OBM_DNARROWI_W:199 case OBM_RGARROWI_W:200 case OBM_LFARROWI_W:172 case OBM_UPARROW_W: 173 case OBM_DNARROW_W: 174 case OBM_RGARROW_W: 175 case OBM_LFARROW_W: 176 case OBM_RESTORE_W: 177 case OBM_RESTORED_W: 178 case OBM_UPARROWD_W: 179 case OBM_DNARROWD_W: 180 case OBM_RGARROWD_W: 181 case OBM_LFARROWD_W: 182 case OBM_OLD_UPARROW_W: 183 case OBM_OLD_DNARROW_W: 184 case OBM_OLD_RGARROW_W: 185 case OBM_OLD_LFARROW_W: 186 case OBM_CHECK_W: 187 case OBM_CHECKBOXES_W: 188 case OBM_BTNCORNERS_W: 189 case OBM_COMBO_W: 190 case OBM_REDUCE_W: 191 case OBM_REDUCED_W: 192 case OBM_ZOOM_W: 193 case OBM_ZOOMD_W: 194 case OBM_SIZE_W: 195 case OBM_CLOSE_W: 196 case OBM_MNARROW_W: 197 case OBM_UPARROWI_W: 198 case OBM_DNARROWI_W: 199 case OBM_RGARROWI_W: 200 case OBM_LFARROWI_W: 201 201 return TRUE; 202 202 203 203 //TODO: Not supported by Open32. Replacement may not be accurate 204 case OBM_OLD_CLOSE_W:204 case OBM_OLD_CLOSE_W: 205 205 *id = OBM_CLOSE_W; 206 206 return TRUE; 207 207 208 case OBM_BTSIZE_W:208 case OBM_BTSIZE_W: 209 209 *id = OBM_SIZE_W; 210 210 return TRUE; 211 211 212 case OBM_OLD_REDUCE_W:212 case OBM_OLD_REDUCE_W: 213 213 *id = OBM_REDUCE_W; 214 214 return TRUE; 215 215 216 case OBM_OLD_ZOOM_W:216 case OBM_OLD_ZOOM_W: 217 217 *id = OBM_ZOOM_W; 218 218 return TRUE; 219 219 220 case OBM_OLD_RESTORE_W:220 case OBM_OLD_RESTORE_W: 221 221 *id = OBM_RESTORE_W; 222 222 return TRUE; 223 223 224 default:224 default: 225 225 return FALSE; 226 226 } … … 229 229 //NOTE: LR_CREATEDIBSECTION flag doesn't work (crash in GDI32)! 230 230 //****************************************************************************** 231 HANDLE LoadBitmapA(HINSTANCE hinst, LPCSTR lpszName, int cxDesired, int cyDesired, 232 UINT fuLoad)231 HANDLE LoadBitmapA(HINSTANCE hinst, LPCSTR lpszName, int cxDesired, int cyDesired, 232 UINT fuLoad) 233 233 { 234 234 HBITMAP hbitmap = 0; … … 249 249 else 250 250 { 251 if (!(ptr = (char *)VIRTUAL_MapFileA( lpszName ))) return 0;252 info = (BITMAPINFO *)(ptr + sizeof(BITMAPFILEHEADER));251 if (!(ptr = (char *)VIRTUAL_MapFileA( lpszName ))) return 0; 252 info = (BITMAPINFO *)(ptr + sizeof(BITMAPFILEHEADER)); 253 253 } 254 254 255 255 //TODO: This has to be removed once pe2lx stores win32 resources!!! 256 if (info->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) && 257 info->bmiHeader.biSize != sizeof(BITMAPINFOHEADER)) 256 if (info->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) && 257 info->bmiHeader.biSize != sizeof(BITMAPINFOHEADER)) 258 258 {//assume it contains a file header first 259 info = (BITMAPINFO *)((char *)info + sizeof(BITMAPFILEHEADER));259 info = (BITMAPINFO *)((char *)info + sizeof(BITMAPFILEHEADER)); 260 260 } 261 261 262 262 size = DIB_BitmapInfoSize(info, DIB_RGB_COLORS); 263 if ((hFix = GlobalAlloc(0, size)) ) fix_info = (BITMAPINFO *)GlobalLock(hFix);263 if ((hFix = GlobalAlloc(0, size)) != NULL) fix_info = (BITMAPINFO *)GlobalLock(hFix); 264 264 if (fix_info) { 265 265 BYTE pix; … … 269 269 DIB_FixColorsToLoadflags(fix_info, fuLoad, pix); 270 270 if ((hdc = GetDC(0)) != 0) { 271 char *bits = (char *)info + size;271 char *bits = (char *)info + size; 272 272 if (fuLoad & LR_CREATEDIBSECTION) { 273 DIBSECTION dib;273 DIBSECTION dib; 274 274 hbitmap = CreateDIBSection(hdc, fix_info, DIB_RGB_COLORS, NULL, 0, 0); 275 GetObjectA(hbitmap, sizeof(DIBSECTION), &dib);276 SetDIBits(hdc, hbitmap, 0, dib.dsBm.bmHeight, bits, info, 277 DIB_RGB_COLORS);278 }279 else {280 hbitmap = CreateDIBitmap( hdc, &fix_info->bmiHeader, CBM_INIT,281 bits, fix_info, DIB_RGB_COLORS );282 } 283 ReleaseDC( 0, hdc );275 GetObjectA(hbitmap, sizeof(DIBSECTION), &dib); 276 SetDIBits(hdc, hbitmap, 0, dib.dsBm.bmHeight, bits, info, 277 DIB_RGB_COLORS); 278 } 279 else { 280 hbitmap = CreateDIBitmap( hdc, &fix_info->bmiHeader, CBM_INIT, 281 bits, fix_info, DIB_RGB_COLORS ); 282 } 283 ReleaseDC( 0, hdc ); 284 284 } 285 285 GlobalUnlock(hFix); … … 303 303 } 304 304 dprintf(("LoadBitmapA returned %08xh\n", hBitmap)); 305 305 306 306 return(hBitmap); 307 307 } … … 317 317 } 318 318 else { 319 if(HIWORD(lpszBitmap) != 0) {319 if(HIWORD(lpszBitmap) != 0) { 320 320 lpszBitmap = (LPWSTR)UnicodeToAsciiString((LPWSTR)lpszBitmap); 321 }321 } 322 322 hBitmap = LoadBitmapA(hinst, (LPSTR)lpszBitmap, 0, 0, 0); 323 323 } … … 327 327 328 328 dprintf(("LoadBitmapW returned %08xh\n", hBitmap)); 329 329 330 330 return(hBitmap); 331 331 } … … 335 335 //****************************************************************************** 336 336 HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType, 337 int cxDesired, int cyDesired, UINT fuLoad)337 int cxDesired, int cyDesired, UINT fuLoad) 338 338 { 339 339 HANDLE hRet = 0; … … 342 342 343 343 if (fuLoad & LR_DEFAULTSIZE) { 344 if (uType == IMAGE_ICON) {344 if (uType == IMAGE_ICON) { 345 345 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXICON); 346 346 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYICON); 347 } 347 } 348 348 else if (uType == IMAGE_CURSOR) { 349 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR);349 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR); 350 350 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYCURSOR); 351 351 } … … 381 381 382 382 if (fuLoad & LR_DEFAULTSIZE) { 383 if (uType == IMAGE_ICON) {383 if (uType == IMAGE_ICON) { 384 384 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXICON); 385 385 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYICON); 386 } 386 } 387 387 else if (uType == IMAGE_CURSOR) { 388 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR);388 if (!cxDesired) cxDesired = GetSystemMetrics(SM_CXCURSOR); 389 389 if (!cyDesired) cyDesired = GetSystemMetrics(SM_CYCURSOR); 390 390 }
Note:
See TracChangeset
for help on using the changeset viewer.
