Changeset 10097 for trunk/src/comctl32/imagelist.c
- Timestamp:
- May 15, 2003, 4:25:14 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/imagelist.c
r9424 r10097 27 27 * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun. 28 28 * 29 * Unless otherwise noted, we beli ve this code to be complete, as per29 * Unless otherwise noted, we believe this code to be complete, as per 30 30 * the specification mentioned above. 31 31 * If you discover missing features, or bugs, please note them below. … … 46 46 #include "winerror.h" 47 47 #include "winbase.h" 48 #include "wine/obj_base.h" 49 #include "wine/obj_storage.h" 48 #include "objbase.h" 50 49 #include "commctrl.h" 51 50 #include "imagelist.h" … … 78 77 79 78 79 static inline BOOL is_valid(HIMAGELIST himl) 80 { 81 return himl && himl->magic == IMAGELIST_MAGIC; 82 } 83 80 84 81 85 /************************************************************************* … … 97 101 IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy) 98 102 { 99 HDC hdc ImageList, hdcBitmap;100 HBITMAP hbmNewBitmap ;103 HDC hdcBitmap; 104 HBITMAP hbmNewBitmap, hbmNull; 101 105 INT nNewWidth, nNewCount; 102 106 … … 110 114 111 115 TRACE("Create expanded bitmaps : himl=%p x=%d y=%d count=%d\n", himl, nNewWidth, cy, nNewCount); 112 hdcImageList = CreateCompatibleDC (0);113 116 hdcBitmap = CreateCompatibleDC (0); 114 117 … … 118 121 ERR("creating new image bitmap (x=%d y=%d)!\n", nNewWidth, cy); 119 122 120 SelectObject (hdcImageList, himl->hbmImage); 121 SelectObject (hdcBitmap, hbmNewBitmap); 123 hbmNull = SelectObject (hdcBitmap, hbmNewBitmap); 122 124 BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy, 123 hdcImageList, 0, 0, SRCCOPY); 124 125 himl->hdcImage, 0, 0, SRCCOPY); 126 127 SelectObject (hdcBitmap, hbmNull); 128 SelectObject (himl->hdcImage, hbmNewBitmap); 125 129 DeleteObject (himl->hbmImage); 126 130 himl->hbmImage = hbmNewBitmap; … … 133 137 ERR("creating new mask bitmap!\n"); 134 138 135 SelectObject (hdcImageList, himl->hbmMask);136 139 SelectObject (hdcBitmap, hbmNewBitmap); 137 140 BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy, 138 hdcImageList, 0, 0, SRCCOPY); 141 himl->hdcMask, 0, 0, SRCCOPY); 142 SelectObject (hdcBitmap, hbmNull); 143 SelectObject (himl->hdcMask, hbmNewBitmap); 139 144 DeleteObject (himl->hbmMask); 140 145 himl->hbmMask = hbmNewBitmap; … … 143 148 himl->cMaxImage = nNewCount; 144 149 145 DeleteDC (hdcImageList);146 150 DeleteDC (hdcBitmap); 147 151 } … … 166 170 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) 167 171 { 168 HDC hdc Image, hdcBitmap;172 HDC hdcBitmap; 169 173 INT nFirstIndex, nImageCount; 170 174 INT nStartX; 171 175 BITMAP bmp; 172 HBITMAP hOldBitmap Image, hOldBitmap;176 HBITMAP hOldBitmap; 173 177 174 178 TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl, hbmImage, hbmMask); 175 if (! himl || !hbmImage)179 if (!is_valid(himl)) 176 180 return -1; 177 181 … … 183 187 nStartX = himl->cCurImage * himl->cx; 184 188 185 hdcImage = CreateCompatibleDC(0);186 189 hdcBitmap = CreateCompatibleDC(0); 187 190 188 hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage);189 191 hOldBitmap = SelectObject(hdcBitmap, hbmImage); 190 192 191 193 /* Copy result to the imagelist 192 194 */ 193 BitBlt (h dcImage, nStartX, 0, bmp.bmWidth, bmp.bmHeight,195 BitBlt (himl->hdcImage, nStartX, 0, bmp.bmWidth, bmp.bmHeight, 194 196 hdcBitmap, 0, 0, SRCCOPY); 195 197 196 198 if(himl->hbmMask) 197 199 { 198 HDC hdcMask, hdcTemp; 199 HBITMAP hOldBitmapMask, hOldBitmapTemp; 200 201 hdcMask = CreateCompatibleDC (0); 200 HDC hdcTemp; 201 HBITMAP hOldBitmapTemp; 202 202 203 hdcTemp = CreateCompatibleDC(0); 203 hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask);204 204 hOldBitmapTemp = SelectObject(hdcTemp, hbmMask); 205 205 206 BitBlt (h dcMask,206 BitBlt (himl->hdcMask, 207 207 nStartX, 0, bmp.bmWidth, bmp.bmHeight, 208 208 hdcTemp, … … 215 215 /* Remove the background from the image 216 216 */ 217 BitBlt (h dcImage,217 BitBlt (himl->hdcImage, 218 218 nStartX, 0, bmp.bmWidth, bmp.bmHeight, 219 h dcMask,219 himl->hdcMask, 220 220 nStartX, 0, 221 221 0x220326); /* NOTSRCAND */ 222 223 SelectObject(hdcMask, hOldBitmapMask); 224 DeleteDC(hdcMask); 225 } 226 227 SelectObject(hdcImage, hOldBitmapImage); 222 } 223 228 224 SelectObject(hdcBitmap, hOldBitmap); 229 DeleteDC(hdcImage);230 225 DeleteDC(hdcBitmap); 231 226 … … 250 245 * Failure: -1 251 246 */ 252 253 INT WINAPI 254 ImageList_AddIcon (HIMAGELIST himl, HICON hIcon) 247 #undef ImageList_AddIcon 248 INT WINAPI ImageList_AddIcon (HIMAGELIST himl, HICON hIcon) 255 249 { 256 250 return ImageList_ReplaceIcon (himl, -1, hIcon); … … 277 271 ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask) 278 272 { 279 HDC hdc Image, hdcMask, hdcBitmap;273 HDC hdcMask, hdcBitmap; 280 274 INT nIndex, nImageCount, nMaskXOffset=0; 281 275 BITMAP bmp; 282 HBITMAP hOldBitmap , hOldBitmapMask, hOldBitmapImage;276 HBITMAP hOldBitmap; 283 277 HBITMAP hMaskBitmap=0; 284 278 COLORREF bkColor; 285 279 286 280 TRACE("himl=%p hbitmap=%p clrmask=%lx\n", himl, hBitmap, clrMask); 287 if ( himl == NULL)281 if (!is_valid(himl)) 288 282 return -1; 289 283 … … 298 292 himl->cCurImage += nImageCount; 299 293 300 hdcMask = CreateCompatibleDC (0);301 hdcImage = CreateCompatibleDC(0);302 294 hdcBitmap = CreateCompatibleDC(0); 303 295 304 296 305 hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage);306 297 hOldBitmap = SelectObject(hdcBitmap, hBitmap); 307 298 if(himl->hbmMask) 308 299 { 309 h OldBitmapMask = SelectObject(hdcMask, himl->hbmMask);300 hdcMask = himl->hdcMask; 310 301 nMaskXOffset = nIndex * himl->cx; 311 302 } … … 316 307 the Image (Windows does this even if there is no mask) 317 308 */ 309 hdcMask = CreateCompatibleDC(0); 318 310 hMaskBitmap = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL); 319 hOldBitmapMask =SelectObject(hdcMask, hMaskBitmap);311 SelectObject(hdcMask, hMaskBitmap); 320 312 nMaskXOffset = 0; 321 313 } … … 348 340 /* Copy result to the imagelist 349 341 */ 350 BitBlt (h dcImage,342 BitBlt (himl->hdcImage, 351 343 nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight, 352 344 hdcBitmap, … … 355 347 /* Clean up 356 348 */ 357 SelectObject(hdcMask,hOldBitmapMask);358 SelectObject(hdcImage, hOldBitmapImage);359 349 SelectObject(hdcBitmap, hOldBitmap); 360 DeleteDC(hdcMask);361 DeleteDC(hdcImage);362 350 DeleteDC(hdcBitmap); 363 351 if(!himl->hbmMask) 364 352 { 365 353 DeleteObject(hMaskBitmap); 354 DeleteDC(hdcMask); 366 355 } 367 356 … … 391 380 INT dxHotspot, INT dyHotspot) 392 381 { 393 HDC hdcSrc, hdcDst;394 382 INT cx, cy; 395 383 … … 397 385 dxHotspot, dyHotspot); 398 386 399 if ( himlTrack == NULL)387 if (!is_valid(himlTrack)) 400 388 return FALSE; 401 389 … … 415 403 InternalDrag.dyHotspot = dyHotspot; 416 404 417 hdcSrc = CreateCompatibleDC (0);418 hdcDst = CreateCompatibleDC (0);419 420 405 /* copy image */ 421 SelectObject (hdcSrc, himlTrack->hbmImage); 422 SelectObject (hdcDst, InternalDrag.himl->hbmImage); 423 BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY); 406 BitBlt (InternalDrag.himl->hdcImage, 0, 0, cx, cy, himlTrack->hdcImage, iTrack * cx, 0, SRCCOPY); 424 407 425 408 /* copy mask */ 426 SelectObject (hdcSrc, himlTrack->hbmMask); 427 SelectObject (hdcDst, InternalDrag.himl->hbmMask); 428 BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY); 429 430 DeleteDC (hdcSrc); 431 DeleteDC (hdcDst); 409 BitBlt (InternalDrag.himl->hdcMask, 0, 0, cx, cy, himlTrack->hdcMask, iTrack * cx, 0, SRCCOPY); 432 410 433 411 InternalDrag.himl->cCurImage = 1; … … 465 443 INT iSrc, INT uFlags) 466 444 { 467 HDC hdcSrc, hdcDst;468 469 445 TRACE("iDst=%d iSrc=%d\n", iDst, iSrc); 470 446 471 if ( (himlSrc == NULL) || (himlDst == NULL))447 if (!is_valid(himlSrc) || !is_valid(himlDst)) 472 448 return FALSE; 473 449 if ((iDst < 0) || (iDst >= himlDst->cCurImage)) … … 476 452 return FALSE; 477 453 478 hdcSrc = CreateCompatibleDC (0);479 if (himlDst == himlSrc)480 hdcDst = hdcSrc;481 else482 hdcDst = CreateCompatibleDC (0);483 484 454 if (uFlags & ILCF_SWAP) { 485 455 /* swap */ 456 HDC hdcBmp; 486 457 HBITMAP hbmTempImage, hbmTempMask; 487 458 459 hdcBmp = CreateCompatibleDC (0); 460 488 461 /* create temporary bitmaps */ 489 462 hbmTempImage = CreateBitmap (himlSrc->cx, himlSrc->cy, 1, … … 494 467 /* copy (and stretch) destination to temporary bitmaps.(save) */ 495 468 /* image */ 496 SelectObject (hdcSrc, himlDst->hbmImage); 497 SelectObject (hdcDst, hbmTempImage); 498 StretchBlt (hdcDst, 0, 0, himlSrc->cx, himlSrc->cy, 499 hdcSrc, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 469 SelectObject (hdcBmp, hbmTempImage); 470 StretchBlt (hdcBmp, 0, 0, himlSrc->cx, himlSrc->cy, 471 himlDst->hdcImage, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 500 472 SRCCOPY); 501 473 /* mask */ 502 SelectObject (hdcSrc, himlDst->hbmMask); 503 SelectObject (hdcDst, hbmTempMask); 504 StretchBlt (hdcDst, 0, 0, himlSrc->cx, himlSrc->cy, 505 hdcSrc, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 474 SelectObject (hdcBmp, hbmTempMask); 475 StretchBlt (hdcBmp, 0, 0, himlSrc->cx, himlSrc->cy, 476 himlDst->hdcMask, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 506 477 SRCCOPY); 507 478 508 479 /* copy (and stretch) source to destination */ 509 480 /* image */ 510 SelectObject (hdcSrc, himlSrc->hbmImage); 511 SelectObject (hdcDst, himlDst->hbmImage); 512 StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 513 hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 481 StretchBlt (himlDst->hdcImage, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 482 himlSrc->hdcImage, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 514 483 SRCCOPY); 515 484 /* mask */ 516 SelectObject (hdcSrc, himlSrc->hbmMask); 517 SelectObject (hdcDst, himlDst->hbmMask); 518 StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 519 hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 485 StretchBlt (himlDst->hdcMask, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 486 himlSrc->hdcMask, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 520 487 SRCCOPY); 521 488 522 489 /* copy (without stretching) temporary bitmaps to source (restore) */ 490 /* mask */ 491 BitBlt (himlSrc->hdcMask, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 492 hdcBmp, 0, 0, SRCCOPY); 493 523 494 /* image */ 524 SelectObject (hdcSrc, hbmTempImage); 525 SelectObject (hdcDst, himlSrc->hbmImage); 526 BitBlt (hdcDst, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 527 hdcSrc, 0, 0, SRCCOPY); 528 /* mask */ 529 SelectObject (hdcSrc, hbmTempMask); 530 SelectObject (hdcDst, himlSrc->hbmMask); 531 BitBlt (hdcDst, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 532 hdcSrc, 0, 0, SRCCOPY); 533 495 BitBlt (himlSrc->hdcImage, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 496 hdcBmp, 0, 0, SRCCOPY); 534 497 /* delete temporary bitmaps */ 535 498 DeleteObject (hbmTempMask); 536 499 DeleteObject (hbmTempImage); 500 DeleteDC(hdcBmp); 537 501 } 538 502 else { 539 503 /* copy image */ 540 SelectObject (hdcSrc, himlSrc->hbmImage); 541 if (himlSrc == himlDst) 542 hdcDst = hdcSrc; 543 else 544 SelectObject (hdcDst, himlDst->hbmImage); 545 StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 546 hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 504 StretchBlt (himlDst->hdcImage, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 505 himlSrc->hdcImage, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 547 506 SRCCOPY); 548 507 549 508 /* copy mask */ 550 SelectObject (hdcSrc, himlSrc->hbmMask); 551 if (himlSrc == himlDst) 552 hdcDst = hdcSrc; 553 else 554 SelectObject (hdcDst, himlDst->hbmMask); 555 StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 556 hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 509 StretchBlt (himlDst->hdcMask, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, 510 himlSrc->hdcMask, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, 557 511 SRCCOPY); 558 512 } 559 560 DeleteDC (hdcSrc);561 if (himlSrc != himlDst)562 DeleteDC (hdcDst);563 513 564 514 return TRUE; … … 586 536 { 587 537 HIMAGELIST himl; 588 HDC hdc;589 538 INT nCount; 590 539 HBITMAP hbmTemp; … … 601 550 return NULL; 602 551 552 cGrow = (cGrow < 4) ? 4 : (cGrow + 3) & ~3; 553 554 himl->magic = IMAGELIST_MAGIC; 603 555 himl->cx = cx; 604 556 himl->cy = cy; … … 607 559 himl->cInitial = cInitial; 608 560 himl->cGrow = cGrow; 609 himl->cCurImage = 0;610 561 himl->clrFg = CLR_DEFAULT; 611 562 himl->clrBk = CLR_NONE; … … 615 566 himl->nOvlIdx[nCount] = -1; 616 567 617 hdc = CreateCompatibleDC (0); 618 himl->uBitsPixel = (UINT)GetDeviceCaps (hdc, BITSPIXEL); 619 DeleteDC (hdc); 568 /* Create Image & Mask DCs */ 569 himl->hdcImage = CreateCompatibleDC (0); 570 if (!himl->hdcImage) 571 goto cleanup; 572 if (himl->flags & ILC_MASK){ 573 himl->hdcMask = CreateCompatibleDC(0); 574 if (!himl->hdcMask) 575 goto cleanup; 576 } 577 578 himl->uBitsPixel = (UINT)GetDeviceCaps (himl->hdcImage, BITSPIXEL); 620 579 621 580 TRACE("Image: %d Bits per Pixel\n", himl->uBitsPixel); … … 627 586 if (himl->hbmImage == 0) { 628 587 ERR("Error creating image bitmap!\n"); 629 return NULL;588 goto cleanup; 630 589 } 631 } 632 else 633 himl->hbmImage = 0; 634 635 if ( (himl->flags & ILC_MASK)) { 636 int images = himl->cMaxImage; 637 if (images <= 0) 638 images = 1; 639 640 himl->hbmMask = CreateBitmap (himl->cx * images, himl->cy, 641 1, 1, NULL); 590 SelectObject(himl->hdcImage, himl->hbmImage); 591 } 592 593 if (himl->flags & ILC_MASK) { 594 himl->hbmMask = 595 CreateBitmap (himl->cx * himl->cMaxImage, himl->cy, 596 1, 1, NULL); 642 597 if (himl->hbmMask == 0) { 643 598 ERR("Error creating mask bitmap!\n"); 644 if (himl->hbmImage) 645 DeleteObject (himl->hbmImage); 646 return NULL; 599 goto cleanup; 647 600 } 648 } 649 else 650 himl->hbmMask = 0; 601 SelectObject(himl->hdcMask, himl->hbmMask); 602 } 651 603 652 604 /* create blending brushes */ … … 661 613 TRACE("created imagelist %p\n", himl); 662 614 return himl; 615 616 cleanup: 617 if (himl) ImageList_Destroy(himl); 618 return NULL; 663 619 } 664 620 … … 680 636 ImageList_Destroy (HIMAGELIST himl) 681 637 { 682 if (! himl)638 if (!is_valid(himl)) 683 639 return FALSE; 684 640 … … 689 645 DeleteObject (himl->hbmMask); 690 646 647 /* delete image & mask DCs */ 648 if (himl->hdcImage) 649 DeleteDC(himl->hdcImage); 650 if (himl->hdcMask) 651 DeleteDC(himl->hdcMask); 652 691 653 /* delete blending brushes */ 692 654 if (himl->hbrBlend25) … … 726 688 TRACE("(hwnd=%p x=%d y=%d)\n", hwndLock, x, y); 727 689 728 if ( InternalDrag.himl == NULL)690 if (!is_valid(InternalDrag.himl)) 729 691 return FALSE; 730 692 … … 848 810 TRACE("(x=%d y=%d)\n", x, y); 849 811 850 if (! InternalDrag.himl) {812 if (!is_valid(InternalDrag.himl)) 851 813 return FALSE; 852 }853 814 854 815 /* draw/update the drag image */ … … 937 898 INT x, y; 938 899 900 if (!is_valid(InternalDrag.himl)) 901 return FALSE; 902 939 903 TRACE("bShow=0x%X!\n", bShow); 940 904 … … 1081 1045 COLORREF clrBk, oldImageBk, oldImageFg; 1082 1046 HDC hImageDC, hImageListDC, hMaskListDC; 1083 HBITMAP hImageBmp, hOldImageBmp, h OldImageListBmp, hOldMaskListBmp, hBlendMaskBmp;1047 HBITMAP hImageBmp, hOldImageBmp, hBlendMaskBmp; 1084 1048 BOOL bIsTransparent, bBlend, bResult = FALSE; 1085 1049 HIMAGELIST himl; 1086 1050 1087 1051 if (!pimldp || !(himl = pimldp->himl)) return FALSE; 1052 if (!is_valid(himl)) return FALSE; 1088 1053 if ((pimldp->i < 0) || (pimldp->i >= himl->cCurImage)) return FALSE; 1089 1054 … … 1103 1068 1104 1069 /* we will use these DCs to access the images and masks in the ImageList */ 1105 hImageListDC = CreateCompatibleDC(0);1106 hMaskListDC = himl->hbmMask ? CreateCompatibleDC(0) : 0;1070 hImageListDC = himl->hdcImage; 1071 hMaskListDC = himl->hdcMask; 1107 1072 1108 1073 /* these will accumulate the image and mask for the image we're drawing */ … … 1116 1081 goto cleanup; 1117 1082 1118 hOldImageListBmp = SelectObject(hImageListDC, himl->hbmImage);1119 1083 hOldImageBmp = SelectObject(hImageDC, hImageBmp); 1120 hOldMaskListBmp = hMaskListDC ? SelectObject(hMaskListDC, himl->hbmMask) : 0;1121 1084 1122 1085 /* … … 1220 1183 SetTextColor(hImageDC, oldImageFg); 1221 1184 SelectObject(hImageDC, hOldImageBmp); 1222 SelectObject(hImageListDC, hOldImageListBmp);1223 if (hMaskListDC) SelectObject(hMaskListDC, hOldMaskListBmp);1224 1185 cleanup: 1225 1186 DeleteObject(hBlendMaskBmp); 1226 1187 DeleteObject(hImageBmp); 1227 1188 DeleteDC(hImageDC); 1228 DeleteDC(hImageListDC);1229 DeleteDC(hMaskListDC);1230 1189 1231 1190 return bResult; … … 1248 1207 { 1249 1208 HIMAGELIST himlDst; 1250 HDC hdcSrc, hdcDst; 1251 1252 if (himlSrc == NULL) { 1209 1210 if (!is_valid(himlSrc)) { 1253 1211 ERR("Invalid image list handle!\n"); 1254 1212 return NULL; … … 1260 1218 if (himlDst) 1261 1219 { 1262 hdcSrc = CreateCompatibleDC (0); 1263 hdcDst = CreateCompatibleDC (0); 1264 SelectObject (hdcSrc, himlSrc->hbmImage); 1265 SelectObject (hdcDst, himlDst->hbmImage); 1266 BitBlt (hdcDst, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy, 1267 hdcSrc, 0, 0, SRCCOPY); 1220 BitBlt (himlDst->hdcImage, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy, 1221 himlSrc->hdcImage, 0, 0, SRCCOPY); 1268 1222 1269 1223 if (himlDst->hbmMask) 1270 { 1271 SelectObject (hdcSrc, himlSrc->hbmMask); 1272 SelectObject (hdcDst, himlDst->hbmMask); 1273 BitBlt (hdcDst, 0, 0, himlSrc->cCurImage * himlSrc->cx, 1274 himlSrc->cy, hdcSrc, 0, 0, SRCCOPY); 1275 } 1276 1277 DeleteDC (hdcDst); 1278 DeleteDC (hdcSrc); 1224 BitBlt (himlDst->hdcMask, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy, 1225 himlSrc->hdcMask, 0, 0, SRCCOPY); 1279 1226 1280 1227 himlDst->cCurImage = himlSrc->cCurImage; … … 1355 1302 ImageList_GetDragImage (POINT *ppt, POINT *pptHotspot) 1356 1303 { 1357 if ( InternalDrag.himl) {1304 if (is_valid(InternalDrag.himl)) { 1358 1305 if (ppt) { 1359 1306 ppt->x = InternalDrag.x; … … 1409 1356 HDC hdcDst; 1410 1357 1411 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) return 0; 1358 TRACE("%p %d %d\n", himl, i, fStyle); 1359 if (!is_valid(himl) || (i < 0) || (i >= himl->cCurImage)) return NULL; 1412 1360 1413 1361 hdcDst = CreateCompatibleDC(0); 1414 1362 1415 1363 ii.fIcon = TRUE; 1364 ii.xHotspot = 0; 1365 ii.yHotspot = 0; 1416 1366 1417 1367 /* draw mask*/ 1418 1368 ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1419 hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask); 1420 ImageList_Draw(himl, i, hdcDst, 0, 0, ILD_MASK); 1369 hOldDstBitmap = SelectObject (hdcDst, ii.hbmMask); 1370 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, WHITENESS); 1371 ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle | ILD_MASK); 1421 1372 1422 1373 /* draw image*/ 1423 SelectObject (hdcDst, himl->hbmImage); 1424 ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1374 ii.hbmColor = CreateCompatibleBitmap (himl->hdcImage, himl->cx, himl->cy); 1425 1375 SelectObject (hdcDst, ii.hbmColor); 1426 ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle); 1376 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1377 ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle | ILD_TRANSPARENT); 1427 1378 1428 1379 /* … … 1463 1414 ImageList_GetIconSize (HIMAGELIST himl, INT *cx, INT *cy) 1464 1415 { 1465 if ( himl == NULL)1416 if (!is_valid(himl)) 1466 1417 return FALSE; 1467 1418 if ((himl->cx <= 0) || (himl->cy <= 0)) … … 1493 1444 ImageList_GetImageCount (HIMAGELIST himl) 1494 1445 { 1495 if ( himl == NULL)1446 if (!is_valid(himl)) 1496 1447 return 0; 1497 1448 … … 1518 1469 ImageList_GetImageInfo (HIMAGELIST himl, INT i, IMAGEINFO *pImageInfo) 1519 1470 { 1520 if ( (himl == NULL) || (pImageInfo == NULL))1471 if (!is_valid(himl) || (pImageInfo == NULL)) 1521 1472 return FALSE; 1522 1473 if ((i < 0) || (i >= himl->cCurImage)) … … 1556 1507 ImageList_GetImageRect (HIMAGELIST himl, INT i, LPRECT lpRect) 1557 1508 { 1558 if ( (himl == NULL) || (lpRect == NULL))1509 if (!is_valid(himl) || (lpRect == NULL)) 1559 1510 return FALSE; 1560 1511 if ((i < 0) || (i >= himl->cCurImage)) … … 1627 1578 himl = ImageList_Create (cx, bmp.bmHeight, ILC_MASK | ILC_COLOR, 1628 1579 nImageCount, cGrow); 1580 if (!himl) { 1581 DeleteObject (handle); 1582 return NULL; 1583 } 1629 1584 ImageList_AddMasked (himl, (HBITMAP)handle, clrMask); 1630 1585 } … … 1637 1592 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1638 1593 ILC_MASK | ILC_COLOR, 1, cGrow); 1594 if (!himl) { 1595 DeleteObject (ii.hbmColor); 1596 DeleteObject (ii.hbmMask); 1597 DeleteObject (handle); 1598 return NULL; 1599 } 1639 1600 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); 1640 1601 DeleteObject (ii.hbmColor); … … 1704 1665 himl = ImageList_Create (cx, bmp.bmHeight, ILC_MASK | ILC_COLOR, 1705 1666 nImageCount, cGrow); 1667 if (!himl) { 1668 DeleteObject (handle); 1669 return NULL; 1670 } 1706 1671 ImageList_AddMasked (himl, (HBITMAP)handle, clrMask); 1707 1672 } … … 1711 1676 1712 1677 GetIconInfo (handle, &ii); 1713 GetObject A(ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);1678 GetObjectW (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 1714 1679 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1715 1680 ILC_MASK | ILC_COLOR, 1, cGrow); 1681 if (!himl) { 1682 DeleteObject (ii.hbmColor); 1683 DeleteObject (ii.hbmMask); 1684 DeleteObject (handle); 1685 return NULL; 1686 } 1716 1687 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); 1717 1688 DeleteObject (ii.hbmColor); … … 1749 1720 { 1750 1721 HIMAGELIST himlDst = NULL; 1751 HDC hdcSrcImage, hdcDstImage;1752 1722 INT cxDst, cyDst; 1753 1723 INT xOff1, yOff1, xOff2, yOff2; … … 1757 1727 i2, dx, dy); 1758 1728 1759 if ( (himl1 == NULL) || (himl2 == NULL))1729 if (!is_valid(himl1) || !is_valid(himl2)) 1760 1730 return NULL; 1761 1731 … … 1804 1774 1805 1775 himlDst = ImageList_Create (cxDst, cyDst, ILC_MASK | ILC_COLOR, 1, 1); 1776 if (!himlDst) 1777 return NULL; 1806 1778 1807 1779 if (himlDst) { 1808 hdcSrcImage = CreateCompatibleDC (0);1809 hdcDstImage = CreateCompatibleDC (0);1810 1780 nX1 = i1 * himl1->cx; 1811 1781 nX2 = i2 * himl2->cx; 1812 1782 1813 1783 /* copy image */ 1814 SelectObject (hdcSrcImage, himl1->hbmImage); 1815 SelectObject (hdcDstImage, himlDst->hbmImage); 1816 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1817 hdcSrcImage, 0, 0, BLACKNESS); 1818 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1819 hdcSrcImage, nX1, 0, SRCCOPY); 1820 1821 SelectObject (hdcSrcImage, himl2->hbmMask); 1822 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1823 hdcSrcImage, nX2, 0, SRCAND); 1824 1825 SelectObject (hdcSrcImage, himl2->hbmImage); 1826 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1827 hdcSrcImage, nX2, 0, SRCPAINT); 1784 BitBlt (himlDst->hdcImage, 0, 0, cxDst, cyDst, himl1->hdcImage, 0, 0, BLACKNESS); 1785 BitBlt (himlDst->hdcImage, xOff1, yOff1, himl1->cx, himl1->cy, himl1->hdcImage, nX1, 0, SRCCOPY); 1786 BitBlt (himlDst->hdcImage, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcMask , nX2, 0, SRCAND); 1787 BitBlt (himlDst->hdcImage, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcImage, nX2, 0, SRCPAINT); 1828 1788 1829 1789 /* copy mask */ 1830 SelectObject (hdcSrcImage, himl1->hbmMask); 1831 SelectObject (hdcDstImage, himlDst->hbmMask); 1832 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1833 hdcSrcImage, 0, 0, WHITENESS); 1834 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1835 hdcSrcImage, nX1, 0, SRCCOPY); 1836 1837 SelectObject (hdcSrcImage, himl2->hbmMask); 1838 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1839 hdcSrcImage, nX2, 0, SRCAND); 1840 1841 DeleteDC (hdcSrcImage); 1842 DeleteDC (hdcDstImage); 1790 BitBlt (himlDst->hdcMask, 0, 0, cxDst, cyDst, himl1->hdcMask, 0, 0, WHITENESS); 1791 BitBlt (himlDst->hdcMask, xOff1, yOff1, himl1->cx, himl1->cy, himl1->hdcMask, nX1, 0, SRCCOPY); 1792 BitBlt (himlDst->hdcMask, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcMask, nX2, 0, SRCAND); 1793 1843 1794 himlDst->cCurImage = 1; 1844 1795 } … … 1862 1813 /* helper for ImageList_Read, see comments below */ 1863 1814 static HBITMAP _read_bitmap(LPSTREAM pstm,int ilcFlag,int cx,int cy) { 1864 HDC xdc =0;1815 HDC xdc = 0, hBitmapDC =0; 1865 1816 BITMAPFILEHEADER bmfh; 1866 1817 BITMAPINFOHEADER bmih; … … 1868 1819 LPBITMAPINFOHEADER bmihc = NULL; 1869 1820 int result = 0; 1870 HBITMAP hbitmap = 0; 1871 LPBYTE bits = NULL,nbits = NULL; 1872 int nbytesperline,bytesperline; 1821 HBITMAP hbitmap = 0, hDIB = 0; 1822 LPBYTE bits = NULL; 1873 1823 1874 1824 if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) || … … 1910 1860 #endif 1911 1861 { 1912 int i,nwidth,nheight;1862 int i,nwidth,nheight,nRows; 1913 1863 1914 1864 nwidth = width*(height/cy); 1915 1865 nheight = cy; 1866 nRows = (height/cy); 1916 1867 1917 1868 if (bitsperpixel==1) … … 1920 1871 hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight); 1921 1872 1922 /* Might be a bit excessive memory use here */ 1923 bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); 1924 nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); 1925 if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL))) 1926 goto ret1; 1873 hDIB = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0); 1874 if (!hDIB) 1875 goto ret1; 1876 if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL))) 1877 goto ret1; 1878 1879 hBitmapDC = CreateCompatibleDC(0); 1880 SelectObject(hBitmapDC, hbitmap); 1927 1881 1928 1882 /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */ 1929 1883 /* Do not forget that windows bitmaps are bottom->top */ 1930 bytesperline = longsperline*4; 1931 nbytesperline = (height/cy)*bytesperline; 1932 for (i=0;i<height;i++) { 1933 memcpy( 1934 nbits+((height-1-i)%cy)*nbytesperline+(i/cy)*bytesperline, 1935 bits+bytesperline*(height-1-i), 1936 bytesperline 1937 ); 1938 } 1939 bmihc->biWidth = nwidth; 1940 bmihc->biHeight = nheight; 1941 if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0)) 1942 goto ret1; 1943 LocalFree((HLOCAL)nbits); 1944 LocalFree((HLOCAL)bits); 1884 TRACE("nRows=%d\n", nRows); 1885 for (i=0; i < nRows; i++){ 1886 StretchDIBits(hBitmapDC, width*i, 0, width, cy, 0, cy*(nRows-1-i), width, cy, bits, 1887 (BITMAPINFO*)bmihc, DIB_RGB_COLORS, SRCCOPY); 1888 } 1889 1945 1890 result = 1; 1946 1891 } … … 1948 1893 if (xdc) ReleaseDC(0,xdc); 1949 1894 if (bmihc) LocalFree((HLOCAL)bmihc); 1895 if (hDIB) DeleteObject(hDIB); 1896 if (hBitmapDC) DeleteDC(hBitmapDC); 1950 1897 if (!result) { 1951 1898 if (hbitmap) { … … 2041 1988 return NULL; 2042 1989 } 1990 SelectObject(himl->hdcImage, hbmColor); 1991 DeleteObject(himl->hbmImage); 2043 1992 himl->hbmImage = hbmColor; 2044 himl->hbmMask = hbmMask; 1993 if (hbmMask){ 1994 SelectObject(himl->hdcMask, hbmMask); 1995 DeleteObject(himl->hbmMask); 1996 himl->hbmMask = hbmMask; 1997 } 2045 1998 himl->cCurImage = ilHead.cCurImage; 2046 1999 himl->cMaxImage = ilHead.cMaxImage; … … 2069 2022 { 2070 2023 HBITMAP hbmNewImage, hbmNewMask; 2071 HDC hdc Src, hdcDst;2024 HDC hdcBmp; 2072 2025 INT cxNew, nCount; 2073 2026 2074 2027 TRACE("(himl=%p i=%d)\n", himl, i); 2075 2028 2076 if ( himl == NULL) {2029 if (!is_valid(himl)) { 2077 2030 ERR("Invalid image list handle!\n"); 2078 2031 return FALSE; … … 2097 2050 himl->nOvlIdx[nCount] = -1; 2098 2051 2052 hbmNewImage = CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2053 1, himl->uBitsPixel, NULL); 2054 SelectObject (himl->hdcImage, hbmNewImage); 2099 2055 DeleteObject (himl->hbmImage); 2100 himl->hbmImage = 2101 CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2102 1, himl->uBitsPixel, NULL); 2056 himl->hbmImage = hbmNewImage; 2103 2057 2104 2058 if (himl->hbmMask) { 2059 hbmNewMask = CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2060 1, 1, NULL); 2061 SelectObject (himl->hdcMask, hbmNewMask); 2105 2062 DeleteObject (himl->hbmMask); 2106 himl->hbmMask = 2107 CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2108 1, 1, NULL); 2063 himl->hbmMask = hbmNewMask; 2109 2064 } 2110 2065 } … … 2129 2084 hbmNewMask = 0; /* Just to keep compiler happy! */ 2130 2085 2131 hdcSrc = CreateCompatibleDC (0); 2132 hdcDst = CreateCompatibleDC (0); 2086 hdcBmp = CreateCompatibleDC (0); 2133 2087 2134 2088 /* copy all images and masks prior to the "removed" image */ … … 2136 2090 TRACE("Pre image copy: Copy %d images\n", i); 2137 2091 2138 SelectObject (hdcSrc, himl->hbmImage); 2139 SelectObject (hdcDst, hbmNewImage); 2140 BitBlt (hdcDst, 0, 0, i * himl->cx, himl->cy, 2141 hdcSrc, 0, 0, SRCCOPY); 2092 SelectObject (hdcBmp, hbmNewImage); 2093 BitBlt (hdcBmp, 0, 0, i * himl->cx, himl->cy, 2094 himl->hdcImage, 0, 0, SRCCOPY); 2142 2095 2143 2096 if (himl->hbmMask) { 2144 SelectObject (hdcSrc, himl->hbmMask); 2145 SelectObject (hdcDst, hbmNewMask); 2146 BitBlt (hdcDst, 0, 0, i * himl->cx, himl->cy, 2147 hdcSrc, 0, 0, SRCCOPY); 2097 SelectObject (hdcBmp, hbmNewMask); 2098 BitBlt (hdcBmp, 0, 0, i * himl->cx, himl->cy, 2099 himl->hdcMask, 0, 0, SRCCOPY); 2148 2100 } 2149 2101 } … … 2152 2104 if (i < himl->cCurImage - 1) { 2153 2105 TRACE("Post image copy!\n"); 2154 SelectObject (hdcSrc, himl->hbmImage); 2155 SelectObject (hdcDst, hbmNewImage); 2156 BitBlt (hdcDst, i * himl->cx, 0, (himl->cCurImage - i - 1) * himl->cx, 2157 himl->cy, hdcSrc, (i + 1) * himl->cx, 0, SRCCOPY); 2106 SelectObject (hdcBmp, hbmNewImage); 2107 BitBlt (hdcBmp, i * himl->cx, 0, (himl->cCurImage - i - 1) * himl->cx, 2108 himl->cy, himl->hdcImage, (i + 1) * himl->cx, 0, SRCCOPY); 2158 2109 2159 2110 if (himl->hbmMask) { 2160 SelectObject (hdcSrc, himl->hbmMask); 2161 SelectObject (hdcDst, hbmNewMask); 2162 BitBlt (hdcDst, i * himl->cx, 0, 2111 SelectObject (hdcBmp, hbmNewMask); 2112 BitBlt (hdcBmp, i * himl->cx, 0, 2163 2113 (himl->cCurImage - i - 1) * himl->cx, 2164 himl->cy, h dcSrc, (i + 1) * himl->cx, 0, SRCCOPY);2114 himl->cy, himl->hdcMask, (i + 1) * himl->cx, 0, SRCCOPY); 2165 2115 } 2166 2116 } 2167 2117 2168 DeleteDC (hdcSrc); 2169 DeleteDC (hdcDst); 2118 DeleteDC (hdcBmp); 2170 2119 2171 2120 /* delete old images and insert new ones */ 2121 SelectObject (himl->hdcImage, hbmNewImage); 2172 2122 DeleteObject (himl->hbmImage); 2173 2123 himl->hbmImage = hbmNewImage; 2174 2124 if (himl->hbmMask) { 2125 SelectObject (himl->hdcMask, hbmNewMask); 2175 2126 DeleteObject (himl->hbmMask); 2176 2127 himl->hbmMask = hbmNewMask; … … 2205 2156 HBITMAP hbmMask) 2206 2157 { 2207 HDC hdcImage List, hdcImage;2158 HDC hdcImage; 2208 2159 BITMAP bmp; 2209 2160 2210 2161 TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask); 2211 2162 2212 if ( himl == NULL) {2163 if (!is_valid(himl)) { 2213 2164 ERR("Invalid image list handle!\n"); 2214 2165 return FALSE; … … 2220 2171 } 2221 2172 2222 hdcImageList = CreateCompatibleDC (0);2223 2173 hdcImage = CreateCompatibleDC (0); 2224 2174 GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp); 2225 2175 2226 2176 /* Replace Image */ 2227 SelectObject (hdcImageList, himl->hbmImage);2228 2177 SelectObject (hdcImage, hbmImage); 2229 2178 2230 StretchBlt (h dcImageList, i * himl->cx, 0, himl->cx, himl->cy,2179 StretchBlt (himl->hdcImage, i * himl->cx, 0, himl->cx, himl->cy, 2231 2180 hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); 2232 2181 … … 2234 2183 { 2235 2184 /* Replace Mask */ 2236 SelectObject (hdcImageList, himl->hbmMask);2237 2185 SelectObject (hdcImage, hbmMask); 2238 2186 2239 StretchBlt (h dcImageList, i * himl->cx, 0, himl->cx, himl->cy,2187 StretchBlt (himl->hdcMask, i * himl->cx, 0, himl->cx, himl->cy, 2240 2188 hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); 2241 2189 … … 2243 2191 /* Remove the background from the image 2244 2192 */ 2245 SelectObject (hdcImageList, himl->hbmImage); 2246 StretchBlt (hdcImageList, 2193 StretchBlt (himl->hdcImage, 2247 2194 i*himl->cx, 0, himl->cx, himl->cy, 2248 2195 hdcImage, … … 2252 2199 2253 2200 DeleteDC (hdcImage); 2254 DeleteDC (hdcImageList);2255 2201 2256 2202 return TRUE; … … 2276 2222 ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon) 2277 2223 { 2278 HDC hdcImage List, hdcImage;2224 HDC hdcImage; 2279 2225 INT nIndex; 2280 2226 HICON hBestFitIcon; 2281 HBITMAP hbmOldSrc , hbmOldDst;2227 HBITMAP hbmOldSrc; 2282 2228 ICONINFO ii; 2283 2229 BITMAP bmp; … … 2285 2231 TRACE("(0x%lx 0x%x %p)\n", (DWORD)himl, i, hIcon); 2286 2232 2287 if ( himl == NULL)2233 if (!is_valid(himl)) 2288 2234 return -1; 2289 2235 if ((i >= himl->cMaxImage) || (i < -1)) … … 2312 2258 nIndex = i; 2313 2259 2314 hdcImageList = CreateCompatibleDC (0);2315 TRACE("hdcImageList=%p!\n", hdcImageList);2316 if (hdcImageList == 0)2317 ERR("invalid hdcImageList!\n");2318 2319 2260 hdcImage = CreateCompatibleDC (0); 2320 TRACE("hdcImage=%p !\n", hdcImage);2261 TRACE("hdcImage=%p\n", hdcImage); 2321 2262 if (hdcImage == 0) 2322 2263 ERR("invalid hdcImage!\n"); 2323 2264 2324 hbmOldDst = SelectObject (hdcImageList, himl->hbmImage); 2325 SetTextColor( hdcImageList, RGB(0,0,0)); 2326 SetBkColor( hdcImageList, RGB(255,255,255)); 2265 SetTextColor(himl->hdcImage, RGB(0,0,0)); 2266 SetBkColor (himl->hdcImage, RGB(255,255,255)); 2327 2267 hbmOldSrc = SelectObject (hdcImage, ii.hbmColor); 2328 StretchBlt (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy, 2268 2269 StretchBlt (himl->hdcImage, nIndex * himl->cx, 0, himl->cx, himl->cy, 2329 2270 hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); 2330 2271 2331 2272 if (himl->hbmMask) { 2332 SelectObject (hdcImageList, himl->hbmMask);2333 2273 SelectObject (hdcImage, ii.hbmMask); 2334 StretchBlt (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy,2274 StretchBlt (himl->hdcMask, nIndex * himl->cx, 0, himl->cx, himl->cy, 2335 2275 hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); 2336 2276 } 2337 2277 2338 2278 SelectObject (hdcImage, hbmOldSrc); 2339 SelectObject (hdcImageList, hbmOldDst);2340 2279 2341 2280 if(hBestFitIcon) 2342 2281 DestroyIcon(hBestFitIcon); 2343 if (hdcImageList)2344 DeleteDC (hdcImageList);2345 2282 if (hdcImage) 2346 2283 DeleteDC (hdcImage); … … 2373 2310 COLORREF clrOldBk; 2374 2311 2375 if ( himl == NULL)2312 if (!is_valid(himl)) 2376 2313 return CLR_NONE; 2377 2314 … … 2411 2348 BOOL visible; 2412 2349 2413 if ( InternalDrag.himl == NULL)2350 if (!is_valid(InternalDrag.himl) || !is_valid(himlDrag)) 2414 2351 return FALSE; 2415 2352 … … 2527 2464 { 2528 2465 INT nCount; 2529 2530 if (!himl) 2466 HBITMAP hbmNew; 2467 2468 if (!is_valid(himl)) 2531 2469 return FALSE; 2532 2470 … … 2541 2479 himl->nOvlIdx[nCount] = -1; 2542 2480 2481 hbmNew = CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2482 1, himl->uBitsPixel, NULL); 2483 SelectObject (himl->hdcImage, hbmNew); 2543 2484 DeleteObject (himl->hbmImage); 2544 himl->hbmImage = 2545 CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2546 1, himl->uBitsPixel, NULL); 2485 himl->hbmImage = hbmNew; 2547 2486 2548 2487 if (himl->hbmMask) { 2488 hbmNew = CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2489 1, 1, NULL); 2490 SelectObject (himl->hdcMask, hbmNew); 2549 2491 DeleteObject (himl->hbmMask); 2550 himl->hbmMask = 2551 CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, 2552 1, 1, NULL); 2492 himl->hbmMask = hbmNew; 2553 2493 } 2554 2494 … … 2574 2514 ImageList_SetImageCount (HIMAGELIST himl, INT iImageCount) 2575 2515 { 2576 HDC hdc ImageList, hdcBitmap;2516 HDC hdcBitmap; 2577 2517 HBITMAP hbmNewBitmap; 2578 2518 INT nNewCount, nCopyCount; … … 2580 2520 TRACE("%p %d\n",himl,iImageCount); 2581 2521 2582 if (! himl)2522 if (!is_valid(himl)) 2583 2523 return FALSE; 2584 2524 if (himl->cCurImage >= iImageCount) … … 2593 2533 nCopyCount = min(himl->cCurImage, iImageCount); 2594 2534 2595 hdcImageList = CreateCompatibleDC (0);2596 2535 hdcBitmap = CreateCompatibleDC (0); 2597 2536 … … 2600 2539 if (hbmNewBitmap != 0) 2601 2540 { 2602 SelectObject (hdcImageList, himl->hbmImage);2603 2541 SelectObject (hdcBitmap, hbmNewBitmap); 2604 2542 2605 2543 /* copy images */ 2606 2544 BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, 2607 hdcImageList, 0, 0, SRCCOPY);2545 himl->hdcImage, 0, 0, SRCCOPY); 2608 2546 #if 0 2609 2547 /* delete 'empty' image space */ … … 2613 2551 (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); 2614 2552 #endif 2553 SelectObject (himl->hdcImage, hbmNewBitmap); 2615 2554 DeleteObject (himl->hbmImage); 2616 2555 himl->hbmImage = hbmNewBitmap; … … 2625 2564 if (hbmNewBitmap != 0) 2626 2565 { 2627 SelectObject (hdcImageList, himl->hbmMask);2628 2566 SelectObject (hdcBitmap, hbmNewBitmap); 2629 2567 2630 2568 /* copy images */ 2631 2569 BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, 2632 hdcImageList, 0, 0, SRCCOPY);2570 himl->hdcMask, 0, 0, SRCCOPY); 2633 2571 #if 0 2634 2572 /* delete 'empty' image space */ … … 2638 2576 (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); 2639 2577 #endif 2578 SelectObject (himl->hdcMask, hbmNewBitmap); 2640 2579 DeleteObject (himl->hbmMask); 2641 2580 himl->hbmMask = hbmNewBitmap; … … 2645 2584 } 2646 2585 2647 DeleteDC (hdcImageList);2648 2586 DeleteDC (hdcBitmap); 2649 2587 … … 2674 2612 ImageList_SetOverlayImage (HIMAGELIST himl, INT iImage, INT iOverlay) 2675 2613 { 2676 if (! himl)2614 if (!is_valid(himl)) 2677 2615 return FALSE; 2678 2616 if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE)) … … 2807 2745 int i; 2808 2746 2809 if (! himl)2747 if (!is_valid(himl)) 2810 2748 return FALSE; 2811 2749
Note:
See TracChangeset
for help on using the changeset viewer.