Ignore:
Timestamp:
Oct 29, 2002, 1:19:36 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/imagelist.c

    r8520 r9370  
    33 *
    44 *  Copyright 1998 Eric Kohl
    5  *            2000 Jason Mawdsley.
    6  *            2001 Michael Stefaniuc
    7  *            2001 Charles Loep for CodeWeavers
     5 *  Copyright 2000 Jason Mawdsley
     6 *  Copyright 2001 Michael Stefaniuc
     7 *  Copyright 2001 Charles Loep for CodeWeavers
     8 *  Copyright 2002 Dimitrie O. Paun
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    2122 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2223 *
     24 * NOTE
     25 *
     26 * This code was audited for completeness against the documented features
     27 * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun.
     28 *
     29 * Unless otherwise noted, we belive this code to be complete, as per
     30 * the specification mentioned above.
     31 * If you discover missing features, or bugs, please note them below.
     32 *
    2333 *  TODO:
    24  *    - Fix ImageList_DrawIndirect (xBitmap, yBitmap, rgbFg, rgbBk, dwRop).
    25  *    - Fix ImageList_GetIcon.
    26  *    - Fix ImageList_SetFilter (undocumented).
    27  *      BTW does anybody know anything about this function???
    28  *        - It removes 12 Bytes from the stack (3 Parameters).
    29  *        - First parameter SHOULD be a HIMAGELIST.
    30  *        - Second parameter COULD be an index?????
    31  *        - Third parameter.... ?????????????????????
    32  *
    33  *  Comments:
    34  *    - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use
    35  *      ImageList_DrawIndirect. Since ImageList_DrawIndirect is still
    36  *      partially implemented, the functions mentioned above will be
    37  *      limited in functionality too.
    38  *
     34 *    - Add support for ILD_PRESERVEALPHA, ILD_SCALE, ILD_DPISCALE
     35 *    - Add support for ILS_GLOW, ILS_SHADOW, ILS_SATURATE, ILS_ALPHA
     36 *
     37 *  FIXME:
    3938 *    - Hotspot handling still not correct. The Hotspot passed to BeginDrag
    4039 *      is the offset of the image position relative to the actual mouse pointer
     
    8180
    8281/*************************************************************************
    83  * IMAGELIST_InternalExpandBitmaps [Internal] 
     82 * IMAGELIST_InternalExpandBitmaps [Internal]
    8483 *
    8584 * Expands the bitmaps of an image list by the given number of images.
     
    9594 *     This function can NOT be used to reduce the number of images.
    9695 */
    97 static VOID
     96static void
    9897IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy)
    9998{
     
    128127
    129128    if (himl->hbmMask) {
    130         hbmNewBitmap = 
     129        hbmNewBitmap =
    131130            CreateBitmap (nNewWidth, cy, 1, 1, NULL);
    132131
     
    150149
    151150/*************************************************************************
    152  * IMAGELIST_InternalDraw [Internal]
    153  *
    154  * Draws the image in the ImageList (without the mask)
    155  *
    156  * PARAMS
    157  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    158  *     cx            [I] the width of the image to display
    159  *     cy............[I] the height of the image to display
    160  *
    161  * RETURNS
    162  *     nothing
    163  *
    164  * NOTES
    165  *     This function is used by ImageList_DrawIndirect, when it is
    166  *     required to draw only the Image (without the mask) to the screen.
    167  *
    168  *     Blending and Overlays styles are accomplished by another function
    169  */
    170 static VOID
    171 IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    172 {
    173     HDC hImageDC;
    174     HBITMAP hOldBitmap;
    175 
    176     hImageDC = CreateCompatibleDC(0);
    177     hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage);
    178     BitBlt(pimldp->hdcDst,
    179         pimldp->x, pimldp->y, cx, cy,
    180         hImageDC,
    181         pimldp->himl->cx * pimldp->i, 0,
    182         SRCCOPY);
    183 
    184     SelectObject(hImageDC, hOldBitmap);
    185     DeleteDC(hImageDC);
    186 }
    187 
    188 
    189 /*************************************************************************
    190  * IMAGELIST_InternalDrawMask [Internal]
    191  *
    192  * Draws the image in the ImageList with the mask
    193  *
    194  * PARAMS
    195  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    196  *     cx            [I] the width of the image to display
    197  *     cy............[I] the height of the image to display
    198  *
    199  * RETURNS
    200  *     nothing
    201  *
    202  * NOTES
    203  *     This function is used by ImageList_DrawIndirect, when it is
    204  *     required to draw the Image with the mask to the screen.
    205  *
    206  *     Blending and Overlays styles are accomplished by another function.
    207  */
    208 static VOID
    209 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    210 {
    211     BOOL bUseCustomBackground, bBlendFlag;
    212     HBRUSH hBrush, hOldBrush;
    213     HDC     hMaskDC, hImageDC;
    214     HBITMAP hOldBitmapImage, hOldBitmapMask;
    215     HIMAGELIST himlLocal = pimldp->himl;
    216     COLORREF oldBkColor, oldFgColor;
    217     UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK);
    218 
    219     /*
    220      * We need a dc and bitmap to draw on that is
    221      * not on the screen.
    222      */
    223     HDC hOffScreenDC = 0;
    224     HBITMAP hOffScreenBmp = 0;
    225 
    226     bUseCustomBackground = (himlLocal->clrBk != CLR_NONE);
    227     bBlendFlag = (fStyle & ILD_BLEND50 ) || (fStyle & ILD_BLEND25);
    228 
    229     hImageDC = CreateCompatibleDC(0);
    230     hMaskDC = CreateCompatibleDC(0);
    231 
    232     /* Create a compatible DC. */
    233     hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst );
    234 
    235     if ( hOffScreenDC )
    236     {
    237         hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
    238 
    239         if ( hOffScreenBmp )
    240             SelectObject( hOffScreenDC, hOffScreenBmp  );
    241         else
    242             goto cleanup;
    243     }
    244     else
    245         goto cleanup;
    246 
    247     hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage);
    248     hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask);
    249    
    250     /*
    251      * Get a copy of the image for the masking operations.
    252      * We will use the copy, and this dc for all the various
    253      * blitting, and then do one final blit to the screen dc.
    254      * This should clean up most of the flickering.
    255      */
    256     BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x,
    257             pimldp->y, SRCCOPY);
    258 
    259     /*
    260      * Draw the Background for the appropriate Styles
    261      */
    262     if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE
    263          || bBlendFlag) )
    264     {
    265        
    266         hBrush = CreateSolidBrush (himlLocal->clrBk);
    267         hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
    268        
    269         PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY );
    270 
    271         DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush));
    272     }
    273 
    274     /*
    275      * Draw Image Transparently over the current background
    276      */
    277     if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) ||
    278        ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag)
    279     {   /*
    280          * To obtain a transparent look, background color should be set
    281          * to white and foreground color to black when blting the
    282          * monochrome mask.
    283          */
    284        
    285         oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) );
    286         oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) );
    287 
    288         BitBlt( hOffScreenDC, 0, 0, cx, cy,hMaskDC, himlLocal->cx * pimldp->i,
    289                 0, SRCAND );
    290 
    291         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i,
    292                 0, SRCPAINT );
    293    
    294     }
    295    
    296     /*
    297      * Draw the image when no Background is specified
    298      */
    299     else if((fStyle & ILD_IMAGE) && !bUseCustomBackground)
    300     {
    301         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,
    302                 himlLocal->cx * pimldp->i, 0, SRCCOPY);
    303     }
    304     /*
    305      * Draw the mask with or without a background
    306      */
    307     else if(fStyle & ILD_MASK)
    308     {
    309         BitBlt( hOffScreenDC, 0, 0, cx, cy, hMaskDC, himlLocal->cx * pimldp->i,
    310                 0, bUseCustomBackground ? SRCCOPY : SRCAND);
    311     }
    312    
    313     /*
    314      * Blit the bitmap to the screen now.
    315      */
    316     BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    317             hOffScreenDC, 0, 0, SRCCOPY);
    318 
    319    
    320     SelectObject(hImageDC, hOldBitmapImage);
    321     SelectObject(hMaskDC, hOldBitmapMask);
    322    
    323 cleanup:
    324    
    325     DeleteDC(hImageDC);
    326     DeleteDC(hMaskDC);
    327    
    328     DeleteDC( hOffScreenDC );
    329     DeleteObject( hOffScreenBmp );
    330    
    331     return;
    332 }
    333 
    334 /*************************************************************************
    335  * IMAGELIST_InternalDrawBlend [Internal]
    336  *
    337  * Draws the Blend over the current image
    338  *
    339  * PARAMS
    340  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    341  *     cx            [I] the width of the image to display
    342  *     cy............[I] the height of the image to display
    343  *
    344  * RETURNS
    345  *     nothing
    346  *
    347  * NOTES
    348  *     This functions is used by ImageList_DrawIndirect, when it is
    349  *     required to add the blend to the current image. 
    350  *     
    351  */
    352 static VOID
    353 IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    354 {
    355 
    356     HDC         hBlendMaskDC,hMaskDC;
    357     HBRUSH      hBlendColorBrush, hBlendBrush, hOldBrush;
    358     HBITMAP     hBlendMaskBitmap, hOldBitmap;
    359     COLORREF    clrBlend, OldTextColor, OldBkColor;
    360     HIMAGELIST  himlLocal = pimldp->himl;
    361 
    362     clrBlend = GetSysColor (COLOR_HIGHLIGHT);
    363     if (!(pimldp->rgbFg == CLR_DEFAULT))
    364     {
    365         clrBlend = pimldp->rgbFg;
    366     }
    367     /* Create the blend Mask
    368     */
    369     hBlendMaskDC = CreateCompatibleDC(0);
    370     hBlendBrush = pimldp->fStyle & ILD_BLEND50 ?
    371         himlLocal->hbrBlend50 : himlLocal->hbrBlend25;
    372 
    373     hBlendMaskBitmap = CreateBitmap(cx, cy, 1, 1, NULL);
    374     hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBitmap);
    375 
    376     hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush);
    377     PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY);
    378     SelectObject(hBlendMaskDC, hOldBrush);
    379 
    380     /* Modify the blend mask if an Image Mask exist
    381     */
    382     if(pimldp->himl->hbmMask != 0)
    383     {
    384         HBITMAP hOldMaskBitmap;
    385         hMaskDC = CreateCompatibleDC(0);
    386         hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask);
    387 
    388         BitBlt(hBlendMaskDC,
    389             0,0, cx, cy,
    390             hMaskDC,
    391             himlLocal->cx * pimldp->i,0,
    392             0x220326); /* NOTSRCAND */
    393 
    394         BitBlt(hBlendMaskDC,
    395             0,0, cx, cy,
    396             hBlendMaskDC,
    397             0,0,
    398             NOTSRCCOPY);
    399 
    400         SelectObject(hMaskDC, hOldMaskBitmap);
    401         DeleteDC(hMaskDC);
    402 
    403     }
    404     /* Apply blend to the current image given the BlendMask
    405     */
    406     OldTextColor = SetTextColor(pimldp->hdcDst, 0);
    407     OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255));
    408     hBlendColorBrush = CreateSolidBrush(clrBlend);
    409     hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush);
    410 
    411     BitBlt (pimldp->hdcDst,
    412         pimldp->x, pimldp->y, cx, cy,
    413         hBlendMaskDC,
    414         0, 0,
    415         0xB8074A); /* PSDPxax */
    416 
    417     SelectObject(pimldp->hdcDst, hOldBrush);
    418     SetTextColor(pimldp->hdcDst, OldTextColor);
    419     SetBkColor(pimldp->hdcDst, OldBkColor);
    420     SelectObject(hBlendMaskDC, hOldBitmap);
    421     DeleteDC(hBlendMaskDC);
    422     DeleteObject(hBlendMaskBitmap);
    423     DeleteObject(hBlendColorBrush);
    424 }
    425 
    426 /*************************************************************************
    427  * IMAGELIST_InternalDrawOverlay [Internal]
    428  *
    429  * Draws the overlay image
    430  *
    431  * PARAMS
    432  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    433  *     cx            [I] the width of the image to display
    434  *     cy............[I] the height of the image to display
    435  *
    436  * RETURNS
    437  *     nothing
    438  *
    439  * NOTES
    440  *     This functions is used by ImageList_DrawIndirect, when it is
    441  *     required to draw the overlay
    442  *
    443  *     
    444  */
    445 static VOID
    446 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    447 {
    448     INT     nOvlIdx;
    449     HDC     hImageDC;
    450     HBITMAP hOldBitmap;
    451 
    452     nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8;
    453     if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE))
    454     {
    455         nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
    456         if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage))
    457         {
    458             hImageDC = CreateCompatibleDC(0);
    459             if (pimldp->himl->hbmMask)
    460             {
    461                 hOldBitmap = (HBITMAP) SelectObject (hImageDC,
    462                     pimldp->himl->hbmMask);
    463 
    464                 BitBlt (pimldp->hdcDst,
    465                     pimldp->x, pimldp->y, cx, cy,
    466                     hImageDC, pimldp->himl->cx * nOvlIdx, 0,
    467                     SRCAND);
    468 
    469                 SelectObject(hImageDC, hOldBitmap);
    470             }
    471             hOldBitmap = (HBITMAP) SelectObject (hImageDC,
    472                 pimldp->himl->hbmImage);
    473 
    474             BitBlt (pimldp->hdcDst,
    475                 pimldp->x, pimldp->y, cx, cy,
    476                 hImageDC,
    477                 pimldp->himl->cx * nOvlIdx, 0,
    478                 SRCPAINT);
    479 
    480             SelectObject(hImageDC, hOldBitmap);
    481             DeleteDC(hImageDC);
    482         }
    483     }
    484 }
    485 
    486 
    487 /*************************************************************************
    488  * ImageList_Add [COMCTL32.40]
     151 * ImageList_Add [COMCTL32.@]
    489152 *
    490153 * Add an image or images to an image list.
     
    509172    HBITMAP hOldBitmapImage, hOldBitmap;
    510173
    511     TRACE("himl=%p hbmimage=%x hbmmask=%x\n", himl, hbmImage, hbmMask);
     174    TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl, hbmImage, hbmMask);
    512175    if (!himl || !hbmImage)
    513176        return -1;
     
    533196    if(himl->hbmMask)
    534197    {
    535         HDC hdcMask, hdcTemp, hOldBitmapMask, hOldBitmapTemp;
     198        HDC hdcMask, hdcTemp;
     199        HBITMAP hOldBitmapMask, hOldBitmapTemp;
    536200
    537201        hdcMask   = CreateCompatibleDC (0);
    538202        hdcTemp   = CreateCompatibleDC(0);
    539         hOldBitmapMask = (HBITMAP) SelectObject(hdcMask, himl->hbmMask);
    540         hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
    541 
    542         BitBlt (hdcMask, 
     203        hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask);
     204        hOldBitmapTemp = SelectObject(hdcTemp, hbmMask);
     205
     206        BitBlt (hdcMask,
    543207            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    544             hdcTemp, 
    545             0, 0, 
     208            hdcTemp,
     209            0, 0,
    546210            SRCCOPY);
    547211
     
    551215        /* Remove the background from the image
    552216        */
    553         BitBlt (hdcImage, 
     217        BitBlt (hdcImage,
    554218            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    555             hdcMask, 
    556             nStartX, 0, 
     219            hdcMask,
     220            nStartX, 0,
    557221            0x220326); /* NOTSRCAND */
    558222
     
    574238
    575239/*************************************************************************
    576  * ImageList_AddIcon [COMCTL32.41]
     240 * ImageList_AddIcon [COMCTL32.@]
    577241 *
    578242 * Adds an icon to an image list.
     
    595259
    596260/*************************************************************************
    597  * ImageList_AddMasked [COMCTL32.42]
     261 * ImageList_AddMasked [COMCTL32.@]
    598262 *
    599263 * Adds an image or images to an image list and creates a mask from the
     
    620284    COLORREF bkColor;
    621285
    622     TRACE("himl=%p hbitmap=%x clrmask=%lx\n", himl, hBitmap, clrMask);
     286    TRACE("himl=%p hbitmap=%p clrmask=%lx\n", himl, hBitmap, clrMask);
    623287    if (himl == NULL)
    624288        return -1;
     
    660324        GetPixel (hdcBitmap, 0, 0);
    661325    SetBkColor (hdcBitmap, bkColor);
    662     BitBlt (hdcMask, 
     326    BitBlt (hdcMask,
    663327        nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight,
    664         hdcBitmap, 0, 0, 
     328        hdcBitmap, 0, 0,
    665329        SRCCOPY);
    666330
     
    677341        This is here in case some apps rely on this bug
    678342    */
    679     BitBlt(hdcBitmap, 
     343    BitBlt(hdcBitmap,
    680344        0, 0, bmp.bmWidth, bmp.bmHeight,
    681         hdcMask, 
    682         nMaskXOffset, 0, 
     345        hdcMask,
     346        nMaskXOffset, 0,
    683347        0x220326); /* NOTSRCAND */
    684348    /* Copy result to the imagelist
    685349    */
    686     BitBlt (hdcImage, 
     350    BitBlt (hdcImage,
    687351        nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
    688         hdcBitmap, 
    689         0, 0, 
     352        hdcBitmap,
     353        0, 0,
    690354        SRCCOPY);
    691355    /* Clean up
     
    707371
    708372/*************************************************************************
    709  * ImageList_BeginDrag [COMCTL32.43]
     373 * ImageList_BeginDrag [COMCTL32.@]
    710374 *
    711375 * Creates a temporary image list that contains one image. It will be used
     
    744408    InternalDrag.himl = ImageList_Create (cx, cy, himlTrack->flags, 1, 1);
    745409    if (InternalDrag.himl == NULL) {
    746         ERR("Error creating drag image list!\n");
     410        WARN("Error creating drag image list!\n");
    747411        return FALSE;
    748412    }
     
    775439
    776440/*************************************************************************
    777  * ImageList_Copy [COMCTL32.44]
    778  *
    779  *  Copies an image of the source image list to an image of the 
     441 * ImageList_Copy [COMCTL32.@]
     442 *
     443 *  Copies an image of the source image list to an image of the
    780444 *  destination image list. Images can be copied or swapped.
    781445 *
     
    801465                INT iSrc, INT uFlags)
    802466{
    803     HDC hdcSrc, hdcDst;   
     467    HDC hdcSrc, hdcDst;
    804468
    805469    TRACE("iDst=%d  iSrc=%d\n", iDst, iSrc);
     
    903567
    904568/*************************************************************************
    905  * ImageList_Create [COMCTL32.45]  Creates a new image list.
     569 * ImageList_Create [COMCTL32.@]  Creates a new image list.
    906570 *
    907571 * PARAMS
     
    925589    INT      nCount;
    926590    HBITMAP  hbmTemp;
    927     static WORD aBitBlend25[] = 
     591    static WORD aBitBlend25[] =
    928592        {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00};
    929593
     
    968632    else
    969633        himl->hbmImage = 0;
    970    
    971     if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
    972         himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
     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,
    973641                                        1, 1, NULL);
    974642        if (himl->hbmMask == 0) {
     
    997665
    998666/*************************************************************************
    999  * ImageList_Destroy [COMCTL32.46]
     667 * ImageList_Destroy [COMCTL32.@]
    1000668 *
    1001669 * Destroys an image list.
     
    1011679BOOL WINAPI
    1012680ImageList_Destroy (HIMAGELIST himl)
    1013 { 
     681{
    1014682    if (!himl)
    1015683        return FALSE;
     
    1026694    if (himl->hbrBlend50)
    1027695        DeleteObject (himl->hbrBlend50);
    1028        
     696
    1029697    COMCTL32_Free (himl);
    1030698
     
    1034702
    1035703/*************************************************************************
    1036  * ImageList_DragEnter [COMCTL32.47]
     704 * ImageList_DragEnter [COMCTL32.@]
    1037705 *
    1038706 * Locks window update and displays the drag image at the given position.
     
    1055723ImageList_DragEnter (HWND hwndLock, INT x, INT y)
    1056724{
    1057     TRACE("(hwnd=%#x x=%d y=%d)\n", hwndLock, x, y);
     725    TRACE("(hwnd=%p x=%d y=%d)\n", hwndLock, x, y);
    1058726
    1059727    if (InternalDrag.himl == NULL)
     
    1078746
    1079747/*************************************************************************
    1080  * ImageList_DragLeave [COMCTL32.48]
     748 * ImageList_DragLeave [COMCTL32.@]
    1081749 *
    1082750 * Unlocks window update and hides the drag image.
     
    1111779
    1112780/*************************************************************************
    1113  * ImageList_DragMove [COMCTL32.49]
     781 * ImageList_InternalDragDraw [Internal]
     782 *
     783 * Draws the drag image.
     784 *
     785 * PARAMS
     786 *     hdc [I] device context to draw into.
     787 *     x   [I] X position of the drag image.
     788 *     y   [I] Y position of the drag image.
     789 *
     790 * RETURNS
     791 *     Success: TRUE
     792 *     Failure: FALSE
     793 *
     794 * NOTES
     795 *     The position of the drag image is relative to the window, not
     796 *     the client area.
     797 *
     798 */
     799
     800static inline void
     801ImageList_InternalDragDraw (HDC hdc, INT x, INT y)
     802{
     803    IMAGELISTDRAWPARAMS imldp;
     804
     805    ZeroMemory (&imldp, sizeof(imldp));
     806    imldp.cbSize  = sizeof(imldp);
     807    imldp.himl    = InternalDrag.himl;
     808    imldp.i       = 0;
     809    imldp.hdcDst  = hdc,
     810    imldp.x       = x;
     811    imldp.y       = y;
     812    imldp.rgbBk   = CLR_DEFAULT;
     813    imldp.rgbFg   = CLR_DEFAULT;
     814    imldp.fStyle  = ILD_NORMAL;
     815    imldp.fState  = ILS_ALPHA;
     816    imldp.Frame   = 128;
     817
     818    /* FIXME: instead of using the alpha blending, we should
     819     * create a 50% mask, and draw it semitransparantly that way */
     820    ImageList_DrawIndirect (&imldp);
     821}
     822
     823/*************************************************************************
     824 * ImageList_DragMove [COMCTL32.@]
    1114825 *
    1115826 * Moves the drag image.
     
    1150861        INT origRegX, origRegY;
    1151862        INT sizeRegX, sizeRegY;
    1152        
     863
    1153864
    1154865        /* calculate the update region */
     
    1182893               hdcOffScreen, origNewX - origRegX, origNewY - origRegY, SRCCOPY);
    1183894        /* draw the image */
    1184         /* FIXME: image should be drawn semitransparent */
    1185         ImageList_Draw(InternalDrag.himl, 0, hdcOffScreen, origNewX - origRegX,
    1186                        origNewY - origRegY, ILD_NORMAL);
     895        ImageList_InternalDragDraw(hdcOffScreen, origNewX - origRegX,
     896                                   origNewY - origRegY);
    1187897        /* draw the update region to the screen */
    1188898        BitBlt(hdcDrag, origRegX, origRegY, sizeRegX, sizeRegY,
     
    1204914
    1205915/*************************************************************************
    1206  * ImageList_DragShowNolock [COMCTL32.50]
     916 * ImageList_DragShowNolock [COMCTL32.@]
    1207917 *
    1208918 * Shows or hides the drag image.
     
    1249959    }
    1250960    SelectObject(hdcBg, InternalDrag.hbmBg);
    1251    
     961
    1252962    if (bShow) {
    1253963        /* save the background */
     
    1255965               hdcDrag, x, y, SRCCOPY);
    1256966        /* show the image */
    1257         /* FIXME: this should be drawn semitransparent */
    1258         ImageList_Draw(InternalDrag.himl, 0, hdcDrag, x, y, ILD_NORMAL);
    1259     } else {
     967        ImageList_InternalDragDraw(hdcDrag, x, y);
     968    } else {
    1260969        /* hide the image */
    1261970        BitBlt(hdcDrag, x, y, InternalDrag.himl->cx, InternalDrag.himl->cy,
     
    1272981
    1273982/*************************************************************************
    1274  * ImageList_Draw [COMCTL32.51] Draws an image.
     983 * ImageList_Draw [COMCTL32.@] Draws an image.
    1275984 *
    1276985 * PARAMS
     
    1286995 *     Failure: FALSE
    1287996 *
    1288  * NOTES
    1289  *     Calls ImageList_DrawIndirect.
    1290  *
    1291997 * SEE
    1292  *     ImageList_DrawIndirect.
     998 *     ImageList_DrawEx.
    1293999 */
    12941000
    12951001BOOL WINAPI
    1296 ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc,
    1297                 INT x, INT y, UINT fStyle)
    1298 {
    1299     IMAGELISTDRAWPARAMS imldp;
    1300 
    1301     imldp.cbSize  = sizeof(IMAGELISTDRAWPARAMS);
    1302     imldp.himl    = himl;
    1303     imldp.i       = i;
    1304     imldp.hdcDst  = hdc,
    1305     imldp.x       = x;
    1306     imldp.y       = y;
    1307     imldp.cx      = 0;
    1308     imldp.cy      = 0;
    1309     imldp.xBitmap = 0;
    1310     imldp.yBitmap = 0;
    1311     imldp.rgbBk   = CLR_DEFAULT;
    1312     imldp.rgbFg   = CLR_DEFAULT;
    1313     imldp.fStyle  = fStyle;
    1314     imldp.dwRop   = 0;
    1315 
    1316     return ImageList_DrawIndirect (&imldp);
    1317 }
    1318 
    1319 
    1320 /*************************************************************************
    1321  * ImageList_DrawEx [COMCTL32.52]
     1002ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
     1003{
     1004    return ImageList_DrawEx (himl, i, hdc, x, y, 0, 0,
     1005                             CLR_DEFAULT, CLR_DEFAULT, fStyle);
     1006}
     1007
     1008
     1009/*************************************************************************
     1010 * ImageList_DrawEx [COMCTL32.@]
    13221011 *
    13231012 * Draws an image and allows to use extended drawing features.
     
    13291018 *     x      [I] X position
    13301019 *     y      [I] Y position
    1331  *     xOffs  [I] X offset
    1332  *     yOffs  [I] Y offset
     1020 *     dx     [I] X offset
     1021 *     dy     [I] Y offset
    13331022 *     rgbBk  [I] background color
    13341023 *     rgbFg  [I] foreground color
     
    13531042    IMAGELISTDRAWPARAMS imldp;
    13541043
    1355     imldp.cbSize  = sizeof(IMAGELISTDRAWPARAMS);
     1044    ZeroMemory (&imldp, sizeof(imldp));
     1045    imldp.cbSize  = sizeof(imldp);
    13561046    imldp.himl    = himl;
    13571047    imldp.i       = i;
     
    13611051    imldp.cx      = dx;
    13621052    imldp.cy      = dy;
    1363     imldp.xBitmap = 0;
    1364     imldp.yBitmap = 0;
    13651053    imldp.rgbBk   = rgbBk;
    13661054    imldp.rgbFg   = rgbFg;
    13671055    imldp.fStyle  = fStyle;
    1368     imldp.dwRop   = 0;
    13691056
    13701057    return ImageList_DrawIndirect (&imldp);
     
    13731060
    13741061/*************************************************************************
    1375  * ImageList_DrawIndirect [COMCTL32.53]
     1062 * ImageList_DrawIndirect [COMCTL32.@]
    13761063 *
    13771064 * Draws an image using ...
     
    13881075ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
    13891076{
    1390     INT      cx, cy;   
    1391     /*
    1392         Do some Error Checking
    1393     */
    1394     if (pimldp == NULL)
    1395         return FALSE;
    1396     if (pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS))
    1397         return FALSE;
    1398     if (pimldp->himl == NULL)
    1399         return FALSE;
    1400     if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) {
    1401         ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
    1402         return FALSE;
    1403     }
     1077    INT cx, cy, nOvlIdx;
     1078    DWORD fState, dwRop;
     1079    UINT fStyle;
     1080    COLORREF clrBk, oldImageBk, oldImageFg;
     1081    HDC hImageDC, hImageListDC, hMaskListDC;
     1082    HBITMAP hImageBmp, hOldImageBmp, hOldImageListBmp, hOldMaskListBmp, hBlendMaskBmp;
     1083    BOOL bIsTransparent, bBlend, bResult = FALSE;
     1084    const HIMAGELIST himl = pimldp->himl;
     1085    const INT lx = himl->cx * pimldp->i + pimldp->xBitmap;
     1086    const INT ly = pimldp->yBitmap;
     1087   
     1088    if (!pimldp || !himl) return FALSE;
     1089    if ((pimldp->i < 0) || (pimldp->i >= himl->cCurImage)) return FALSE;
     1090   
     1091    fState = pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS) ? ILS_NORMAL : pimldp->fState;
     1092    fStyle = pimldp->fStyle & ~ILD_OVERLAYMASK;
     1093    cx = (pimldp->cx == 0) ? himl->cx : pimldp->cx;
     1094    cy = (pimldp->cy == 0) ? himl->cy : pimldp->cy;
     1095    clrBk = (pimldp->rgbBk == CLR_DEFAULT) ? himl->clrBk : pimldp->rgbBk;
     1096    bIsTransparent = (fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE;
     1097    bBlend = fStyle & (ILD_BLEND25 | ILD_BLEND50);
     1098
     1099    TRACE("hbmMask(%p) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n",
     1100          himl->hbmMask, pimldp->i, pimldp->x, pimldp->y, cx, cy);
     1101
     1102    /* we will use these DCs to access the images and masks in the ImageList */
     1103    hImageListDC = CreateCompatibleDC(0);
     1104    hMaskListDC = himl->hbmMask ? CreateCompatibleDC(0) : 0;
     1105
     1106    /* these will accumulate the image and mask for the image we're drawing */
     1107    hImageDC = CreateCompatibleDC( pimldp->hdcDst );
     1108    hImageBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
     1109    hBlendMaskBmp = bBlend ? CreateBitmap(cx, cy, 1, 1, NULL) : 0;
     1110
     1111    /* Create a compatible DC. */
     1112    if (!hImageListDC || !hImageDC || !hImageBmp ||
     1113        (bBlend && !hBlendMaskBmp) || (himl->hbmMask && !hMaskListDC))
     1114        goto cleanup;
     1115   
     1116    hOldImageListBmp = SelectObject(hImageListDC, himl->hbmImage);
     1117    hOldImageBmp = SelectObject(hImageDC, hImageBmp);
     1118    hOldMaskListBmp = hMaskListDC ? SelectObject(hMaskListDC, himl->hbmMask) : 0;
     1119 
    14041120    /*
    1405         Get the Height and Width to display
    1406     */
    1407     cx = (pimldp->cx == 0) ? pimldp->himl->cx : pimldp->cx;
    1408     cy = (pimldp->cy == 0) ? pimldp->himl->cy : pimldp->cy;
     1121     * To obtain a transparent look, background color should be set
     1122     * to white and foreground color to black when blting the
     1123     * monochrome mask.
     1124     */
     1125    oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) );
     1126    oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) );
     1127
    14091128    /*
    1410         Draw the image
    1411     */
    1412     if(pimldp->himl->hbmMask != 0)
    1413     {
    1414         IMAGELIST_InternalDrawMask(pimldp, cx, cy);
    1415     }
    1416     else
    1417     {
    1418         IMAGELIST_InternalDraw(pimldp, cx, cy);
    1419     }
    1420     /*
    1421         Apply the blend if needed to the Image
    1422     */
    1423     if((pimldp->fStyle & ILD_BLEND50)
    1424         || (pimldp->fStyle & ILD_BLEND25))
    1425     {
    1426         IMAGELIST_InternalDrawBlend(pimldp, cx, cy);
    1427     }
    1428     /*
    1429         Apply the Overlay if needed
    1430     */
    1431     if (pimldp->fStyle & ILD_OVERLAYMASK)
    1432     {
    1433         IMAGELIST_InternalDrawOverlay(pimldp, cx, cy);
    1434     }
    1435 
    1436     return TRUE;
    1437 }
    1438 
    1439 
    1440 /*************************************************************************
    1441  * ImageList_Duplicate [COMCTL32.54] Duplicates an image list.
     1129     * Draw the initial image
     1130     */
     1131    if(fStyle & ILD_MASK) {
     1132        if (himl->hbmMask) {
     1133            BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY);
     1134        } else {
     1135            HBRUSH hOldBrush = SelectObject (hImageDC, GetStockObject(BLACK_BRUSH));
     1136            PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY);
     1137            SelectObject(hImageDC, hOldBrush);
     1138        }
     1139    } else if (himl->hbmMask && !bIsTransparent) {
     1140        /* blend the image with the needed solid background */
     1141        HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk));
     1142        PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
     1143        BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND );
     1144        BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT );
     1145        DeleteObject (SelectObject (hImageDC, hOldBrush));
     1146    } else {
     1147        /* start off with the image, if we have a mask, we'll use it later */
     1148        BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCCOPY);
     1149    }
     1150 
     1151    /* Time for blending, if required */
     1152    if (bBlend) {
     1153        HBRUSH hBlendBrush, hOldBrush;
     1154        COLORREF clrBlend = pimldp->rgbFg;
     1155        HDC hBlendMaskDC = hImageListDC;
     1156        HBITMAP hOldBitmap;
     1157
     1158        /* Create the blend Mask */
     1159        hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBmp);
     1160        hBlendBrush = fStyle & ILD_BLEND50 ? himl->hbrBlend50 : himl->hbrBlend25;
     1161        hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush);
     1162        PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY);
     1163        SelectObject(hBlendMaskDC, hOldBrush);
     1164
     1165        /* Modify the blend mask if an Image Mask exist */
     1166        if(himl->hbmMask) {
     1167            BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskListDC, lx, ly, 0x220326); /* NOTSRCAND */
     1168            BitBlt(hBlendMaskDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, NOTSRCCOPY);
     1169        }
     1170       
     1171        /* now apply blend to the current image given the BlendMask */
     1172        if (clrBlend == CLR_DEFAULT) clrBlend = GetSysColor (COLOR_HIGHLIGHT);
     1173        else if (clrBlend == CLR_NONE) clrBlend = GetTextColor (pimldp->hdcDst);
     1174        hOldBrush = (HBRUSH) SelectObject (hImageDC, CreateSolidBrush(clrBlend));
     1175        BitBlt (hImageDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, 0xB8074A); /* PSDPxax */
     1176        DeleteObject(SelectObject(hImageDC, hOldBrush));
     1177        SelectObject(hBlendMaskDC, hOldBitmap);
     1178    }
     1179   
     1180    /* Now do the overlay image, if any */
     1181    nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8;
     1182    if ( (nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) {
     1183        nOvlIdx = himl->nOvlIdx[nOvlIdx - 1];
     1184        if ((nOvlIdx >= 0) && (nOvlIdx < himl->cCurImage)) {
     1185            const INT ox = himl->cx * nOvlIdx + pimldp->xBitmap;
     1186            if (himl->hbmMask && !(fStyle & ILD_IMAGE))
     1187                BitBlt (hImageDC, 0, 0, cx, cy, hMaskListDC, ox, ly, SRCAND);
     1188            BitBlt (hImageDC, 0, 0, cx, cy, hImageListDC, ox, ly, SRCPAINT);
     1189        }
     1190    }
     1191
     1192    if (fState & ILS_SATURATE) FIXME("ILS_SATURATE: unimplemented!\n");
     1193    if (fState & ILS_GLOW) FIXME("ILS_GLOW: unimplemented!\n");
     1194    if (fState & ILS_SHADOW) FIXME("ILS_SHADOW: unimplemented!\n");
     1195    if (fState & ILS_ALPHA) FIXME("ILS_SHADOW: unimplemented!\n");
     1196
     1197    if (fStyle & ILD_PRESERVEALPHA) FIXME("ILD_PRESERVEALPHA: unimplemented!\n");
     1198    if (fStyle & ILD_SCALE) FIXME("ILD_SCALE: unimplemented!\n");
     1199    if (fStyle & ILD_DPISCALE) FIXME("ILD_DPISCALE: unimplemented!\n");
     1200   
     1201    /* now copy the image to the screen */
     1202    dwRop = SRCCOPY;
     1203    if (himl->hbmMask && bIsTransparent && !(fStyle & ILD_MASK)) {
     1204        COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) );
     1205        COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff ));
     1206        BitBlt (pimldp->hdcDst, pimldp->x,  pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND);
     1207        SetBkColor(pimldp->hdcDst, oldDstBk);
     1208        SetTextColor(pimldp->hdcDst, oldDstFg);
     1209        dwRop = SRCPAINT;
     1210    }
     1211    if (fStyle & ILD_ROP) dwRop = pimldp->dwRop;
     1212    BitBlt (pimldp->hdcDst, pimldp->x,  pimldp->y, cx, cy, hImageDC, 0, 0, dwRop);
     1213
     1214    bResult = TRUE;
     1215   
     1216    /* cleanup the mess */
     1217    SetBkColor(hImageDC, oldImageBk);
     1218    SetTextColor(hImageDC, oldImageFg);
     1219    SelectObject(hImageDC, hOldImageBmp);
     1220    SelectObject(hImageListDC, hOldImageListBmp);
     1221    if (hMaskListDC) SelectObject(hMaskListDC, hOldMaskListBmp);
     1222cleanup:
     1223    DeleteObject(hBlendMaskBmp);
     1224    DeleteObject(hImageBmp);
     1225    DeleteObject(hImageDC);
     1226    DeleteObject(hImageListDC);
     1227    DeleteObject(hMaskListDC);
     1228
     1229    return bResult;
     1230}
     1231
     1232
     1233/*************************************************************************
     1234 * ImageList_Duplicate [COMCTL32.@] Duplicates an image list.
    14421235 *
    14431236 * PARAMS
     
    14911284
    14921285/*************************************************************************
    1493  * ImageList_EndDrag [COMCTL32.55] Finishes a drag operation.
     1286 * ImageList_EndDrag [COMCTL32.@] Finishes a drag operation.
    14941287 *
    14951288 * Finishes a drag operation.
     
    15241317
    15251318/*************************************************************************
    1526  * ImageList_GetBkColor [COMCTL32.56]
     1319 * ImageList_GetBkColor [COMCTL32.@]
    15271320 *
    15281321 * Returns the background color of an image list.
     
    15391332ImageList_GetBkColor (HIMAGELIST himl)
    15401333{
    1541     if (himl == NULL)
    1542         return CLR_NONE;
    1543 
    1544     return himl->clrBk;
    1545 }
    1546 
    1547 
    1548 /*************************************************************************
    1549  * ImageList_GetDragImage [COMCTL32.57]
     1334    return himl ? himl->clrBk : CLR_NONE;
     1335}
     1336
     1337
     1338/*************************************************************************
     1339 * ImageList_GetDragImage [COMCTL32.@]
    15501340 *
    15511341 * Returns the handle to the internal drag image list.
     
    15801370
    15811371/*************************************************************************
    1582  * ImageList_GetFlags [COMCTL32.58]
     1372 * ImageList_GetFlags [COMCTL32.@]
    15831373 *
    15841374 * BUGS
     
    15951385
    15961386/*************************************************************************
    1597  * ImageList_GetIcon [COMCTL32.59]
     1387 * ImageList_GetIcon [COMCTL32.@]
    15981388 *
    15991389 * Creates an icon from a masked image of an image list.
     
    16131403{
    16141404    ICONINFO ii;
    1615     HICON  hIcon;
    1616     HBITMAP hOldSrcBitmap,hOldDstBitmap;
    1617     HDC    hdcSrc, hdcDst;
    1618 
    1619     if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) {
    1620         FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
    1621         return 0;
    1622    }
    1623 
    1624     hdcSrc = CreateCompatibleDC(0);
     1405    HICON hIcon;
     1406    HBITMAP hOldDstBitmap;
     1407    HDC hdcDst;
     1408
     1409    if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) return 0;
     1410
    16251411    hdcDst = CreateCompatibleDC(0);
    16261412
    16271413    ii.fIcon = TRUE;
     1414
     1415    /* draw mask*/
    16281416    ii.hbmMask  = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);
    1629 
    1630     /* draw mask*/
    16311417    hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask);
    1632     if (himl->hbmMask) {
    1633         SelectObject (hdcSrc, himl->hbmMask);
    1634         BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1635                   hdcSrc, i * himl->cx, 0, SRCCOPY);
    1636     }
    1637     else
    1638         PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
     1418    ImageList_Draw(himl, i, hdcDst, 0, 0, ILD_MASK);
    16391419
    16401420    /* draw image*/
    1641     hOldSrcBitmap = (HBITMAP)SelectObject (hdcSrc, himl->hbmImage);
    1642     ii.hbmColor = CreateCompatibleBitmap (hdcSrc, himl->cx, himl->cy);
     1421    SelectObject (hdcDst, himl->hbmImage);
     1422    ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);
    16431423    SelectObject (hdcDst, ii.hbmColor);
    1644     BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1645               hdcSrc, i * himl->cx, 0, SRCCOPY);
     1424    ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle);
    16461425
    16471426    /*
    16481427     * CreateIconIndirect requires us to deselect the bitmaps from
    1649      * the DCs before calling 
     1428     * the DCs before calling
    16501429     */
    1651     SelectObject(hdcSrc, hOldSrcBitmap);
    16521430    SelectObject(hdcDst, hOldDstBitmap);
    16531431
    1654     hIcon = CreateIconIndirect (&ii);   
    1655 
    1656     DeleteDC (hdcSrc);
    1657     DeleteDC (hdcDst);
     1432    hIcon = CreateIconIndirect (&ii);
     1433
    16581434    DeleteObject (ii.hbmMask);
    16591435    DeleteObject (ii.hbmColor);
     1436    DeleteDC (hdcDst);
    16601437
    16611438    return hIcon;
     
    16641441
    16651442/*************************************************************************
    1666  * ImageList_GetIconSize [COMCTL32.60]
     1443 * ImageList_GetIconSize [COMCTL32.@]
    16671444 *
    16681445 * Retrieves the size of an image in an image list.
     
    16991476
    17001477/*************************************************************************
    1701  * ImageList_GetImageCount [COMCTL32.61]
     1478 * ImageList_GetImageCount [COMCTL32.@]
    17021479 *
    17031480 * Returns the number of images in an image list.
     
    17221499
    17231500/*************************************************************************
    1724  * ImageList_GetImageInfo [COMCTL32.62]
     1501 * ImageList_GetImageInfo [COMCTL32.@]
    17251502 *
    17261503 * Returns information about an image in an image list.
     
    17461523    pImageInfo->hbmImage = himl->hbmImage;
    17471524    pImageInfo->hbmMask  = himl->hbmMask;
    1748    
     1525
    17491526    pImageInfo->rcImage.top    = 0;
    17501527    pImageInfo->rcImage.bottom = himl->cy;
    17511528    pImageInfo->rcImage.left   = i * himl->cx;
    17521529    pImageInfo->rcImage.right  = (i+1) * himl->cx;
    1753    
     1530
    17541531    return TRUE;
    17551532}
     
    17571534
    17581535/*************************************************************************
    1759  * ImageList_GetImageRect [COMCTL32.63]
     1536 * ImageList_GetImageRect [COMCTL32.@]
    17601537 *
    17611538 * Retrieves the rectangle of the specified image in an image list.
     
    17921569
    17931570/*************************************************************************
    1794  * ImageList_LoadImage  [COMCTL32.64]
    1795  * ImageList_LoadImageA [COMCTL32.65]
     1571 * ImageList_LoadImage  [COMCTL32.@]
     1572 * ImageList_LoadImageA [COMCTL32.@]
    17961573 *
    17971574 * Creates an image list from a bitmap, icon or cursor.
     
    18561633        GetIconInfo (handle, &ii);
    18571634        GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp);
    1858         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1635        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    18591636                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    18601637        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    18641641
    18651642    DeleteObject (handle);
    1866    
     1643
    18671644    return himl;
    18681645}
     
    18701647
    18711648/*************************************************************************
    1872  * ImageList_LoadImageW [COMCTL32.66]
     1649 * ImageList_LoadImageW [COMCTL32.@]
    18731650 *
    18741651 * Creates an image list from a bitmap, icon or cursor.
     
    19331710        GetIconInfo (handle, &ii);
    19341711        GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    1935         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1712        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    19361713                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    19371714        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    19411718
    19421719    DeleteObject (handle);
    1943    
     1720
    19441721    return himl;
    19451722}
     
    19471724
    19481725/*************************************************************************
    1949  * ImageList_Merge [COMCTL32.67]
     1726 * ImageList_Merge [COMCTL32.@]
    19501727 *
    19511728 * Creates a new image list that contains a merged image from the specified
     
    20311808        nX1 = i1 * himl1->cx;
    20321809        nX2 = i2 * himl2->cx;
    2033        
     1810
    20341811        /* copy image */
    20351812        SelectObject (hdcSrcImage, himl1->hbmImage);
    20361813        SelectObject (hdcDstImage, himlDst->hbmImage);
    2037         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1814        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    20381815                  hdcSrcImage, 0, 0, BLACKNESS);
    2039         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1816        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    20401817                  hdcSrcImage, nX1, 0, SRCCOPY);
    20411818
    20421819        SelectObject (hdcSrcImage, himl2->hbmMask);
    2043         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1820        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    20441821                  hdcSrcImage, nX2, 0, SRCAND);
    20451822
    20461823        SelectObject (hdcSrcImage, himl2->hbmImage);
    2047         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1824        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    20481825                  hdcSrcImage, nX2, 0, SRCPAINT);
    20491826
     
    20511828        SelectObject (hdcSrcImage, himl1->hbmMask);
    20521829        SelectObject (hdcDstImage, himlDst->hbmMask);
    2053         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1830        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    20541831                  hdcSrcImage, 0, 0, WHITENESS);
    2055         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1832        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    20561833                  hdcSrcImage, nX1, 0, SRCCOPY);
    20571834
    20581835        SelectObject (hdcSrcImage, himl2->hbmMask);
    2059         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1836        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    20601837                  hdcSrcImage, nX2, 0, SRCAND);
    20611838
     
    20641841        himlDst->cCurImage = 1;
    20651842    }
    2066    
     1843
    20671844    return himlDst;
    20681845}
     
    21791956
    21801957/*************************************************************************
    2181  * ImageList_Read [COMCTL32.68]
     1958 * ImageList_Read [COMCTL32.@]
    21821959 *
    21831960 * Reads an image list from a stream.
     
    21941971 *
    21951972 * for the color image part:
    2196  *      BITMAPFILEHEADER        bmfh; 
     1973 *      BITMAPFILEHEADER        bmfh;
    21971974 *      BITMAPINFOHEADER        bmih;
    21981975 * only if it has a palette:
    2199  *      RGBQUAD         rgbs[nr_of_paletted_colors]; 
     1976 *      RGBQUAD         rgbs[nr_of_paletted_colors];
    22001977 *
    22011978 *      BYTE                    colorbits[imagesize];
     
    22051982 *      BITMAPINFOHEADER        bmih_mask;
    22061983 * only if it has a palette (it usually does not):
    2207  *      RGBQUAD         rgbs[nr_of_paletted_colors]; 
     1984 *      RGBQUAD         rgbs[nr_of_paletted_colors];
    22081985 *
    22091986 *      BYTE                    maskbits[imagesize];
     
    22752052
    22762053/*************************************************************************
    2277  * ImageList_Remove [COMCTL32.69] Removes an image from an image list
     2054 * ImageList_Remove [COMCTL32.@] Removes an image from an image list
    22782055 *
    22792056 * PARAMS
     
    22932070    INT     cxNew, nCount;
    22942071
     2072    TRACE("(himl=%p i=%d)\n", himl, i);
     2073
    22952074    if (himl == NULL) {
    22962075        ERR("Invalid image list handle!\n");
    22972076        return FALSE;
    22982077    }
    2299    
     2078
    23002079    if ((i < -1) || (i >= himl->cCurImage)) {
    23012080        ERR("index out of range! %d\n", i);
     
    23032082    }
    23042083
    2305     if (himl->cCurImage == 0) {
    2306         ERR("image list is already empty!\n");
    2307         return FALSE;
    2308     }
    2309 
    23102084    if (i == -1) {
    23112085        /* remove all */
    2312         TRACE("remove all!\n");
     2086        if (himl->cCurImage == 0) {
     2087            /* remove all on empty ImageList is allowed */
     2088            TRACE("remove all on empty ImageList!\n");
     2089            return TRUE;
     2090        }
    23132091
    23142092        himl->cMaxImage = himl->cInitial + himl->cGrow;
     
    23402118        TRACE(" - Max. number of images: %d / %d (Old/New)\n",
    23412119                 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1);
    2342        
     2120
    23432121        hbmNewImage =
    23442122            CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL);
     
    23552133        if (i > 0) {
    23562134            TRACE("Pre image copy: Copy %d images\n", i);
    2357        
     2135
    23582136            SelectObject (hdcSrc, himl->hbmImage);
    23592137            SelectObject (hdcDst, hbmNewImage);
     
    24062184
    24072185/*************************************************************************
    2408  * ImageList_Replace [COMCTL32.70]
     2186 * ImageList_Replace [COMCTL32.@]
    24092187 *
    24102188 * Replaces an image in an image list with a new image.
     
    24282206    BITMAP bmp;
    24292207
     2208    TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask);
     2209
    24302210    if (himl == NULL) {
    24312211        ERR("Invalid image list handle!\n");
    24322212        return FALSE;
    24332213    }
    2434    
     2214
    24352215    if ((i >= himl->cMaxImage) || (i < 0)) {
    24362216        ERR("Invalid image index!\n");
     
    24622242        */
    24632243        SelectObject (hdcImageList, himl->hbmImage);
    2464         StretchBlt (hdcImageList, 
     2244        StretchBlt (hdcImageList,
    24652245            i*himl->cx, 0, himl->cx, himl->cy,
    2466             hdcImage, 
    2467             0, 0, bmp.bmWidth, bmp.bmHeight, 
     2246            hdcImage,
     2247            0, 0, bmp.bmWidth, bmp.bmHeight,
    24682248            0x220326); /* NOTSRCAND */
    24692249    }
     
    24772257
    24782258/*************************************************************************
    2479  * ImageList_ReplaceIcon [COMCTL32.75]
     2259 * ImageList_ReplaceIcon [COMCTL32.@]
    24802260 *
    24812261 * Replaces an image in an image list using an icon.
     
    25012281    BITMAP  bmp;
    25022282
    2503     TRACE("(0x%lx 0x%x 0x%x)\n", (DWORD)himl, i, hIcon);
     2283    TRACE("(0x%lx 0x%x %p)\n", (DWORD)himl, i, hIcon);
    25042284
    25052285    if (himl == NULL)
     
    25092289
    25102290    hBestFitIcon = CopyImage(
    2511         hIcon, IMAGE_ICON, 
    2512         himl->cx, himl->cy, 
     2291        hIcon, IMAGE_ICON,
     2292        himl->cx, himl->cy,
    25132293        LR_COPYFROMRESOURCE);
    25142294
     
    25312311
    25322312    hdcImageList = CreateCompatibleDC (0);
    2533     TRACE("hdcImageList=0x%x!\n", hdcImageList);
     2313    TRACE("hdcImageList=%p!\n", hdcImageList);
    25342314    if (hdcImageList == 0)
    25352315        ERR("invalid hdcImageList!\n");
    25362316
    25372317    hdcImage = CreateCompatibleDC (0);
    2538     TRACE("hdcImage=0x%x!\n", hdcImage);
     2318    TRACE("hdcImage=%p!\n", hdcImage);
    25392319    if (hdcImage == 0)
    25402320        ERR("invalid hdcImage!\n");
     
    25732353
    25742354/*************************************************************************
    2575  * ImageList_SetBkColor [COMCTL32.76]
     2355 * ImageList_SetBkColor [COMCTL32.@]
    25762356 *
    25772357 * Sets the background color of an image list.
     
    26012381
    26022382/*************************************************************************
    2603  * ImageList_SetDragCursorImage [COMCTL32.77]
     2383 * ImageList_SetDragCursorImage [COMCTL32.@]
    26042384 *
    26052385 * Combines the specified image with the current drag image
     
    26832463
    26842464/*************************************************************************
    2685  * ImageList_SetFilter [COMCTL32.78]
     2465 * ImageList_SetFilter [COMCTL32.@]
    26862466 *
    26872467 * Sets a filter (or does something completely different)!!???
    2688  *
    2689  * PARAMS
    2690  *     himl     [I] handle to image list
    2691  *     i        [I] ???
     2468 * It removes 12 Bytes from the stack (3 Parameters).
     2469 *
     2470 * PARAMS
     2471 *     himl     [I] SHOULD be a handle to image list
     2472 *     i        [I] COULD be an index?
    26922473 *     dwFilter [I] ???
    26932474 *
     
    27042485ImageList_SetFilter (HIMAGELIST himl, INT i, DWORD dwFilter)
    27052486{
    2706     FIXME("(%p 0x%x 0x%lx):empty stub!\n",
    2707            himl, i, dwFilter);
     2487    FIXME("(%p 0x%x 0x%lx):empty stub!\n", himl, i, dwFilter);
    27082488
    27092489    return FALSE;
     
    27122492
    27132493/*************************************************************************
    2714  * ImageList_SetFlags [COMCTL32.79]
     2494 * ImageList_SetFlags [COMCTL32.@]
    27152495 *
    27162496 * BUGS
     
    27272507
    27282508/*************************************************************************
    2729  * ImageList_SetIconSize [COMCTL32.80]
     2509 * ImageList_SetIconSize [COMCTL32.@]
    27302510 *
    27312511 * Sets the image size of the bitmap and deletes all images.
     
    27762556
    27772557/*************************************************************************
    2778  * ImageList_SetImageCount [COMCTL32.81]
     2558 * ImageList_SetImageCount [COMCTL32.@]
    27792559 *
    27802560 * Resizes an image list to the specified number of images.
     
    27952575    HBITMAP hbmNewBitmap;
    27962576    INT     nNewCount, nCopyCount;
     2577
     2578    TRACE("%p %d\n",himl,iImageCount);
    27972579
    27982580    if (!himl)
     
    28012583        return FALSE;
    28022584    if (himl->cMaxImage > iImageCount)
     2585    {
     2586        himl->cCurImage = iImageCount;
    28032587        return TRUE;
     2588    }
    28042589
    28052590    nNewCount = iImageCount + himl->cGrow;
     
    28232608        SetBkColor (hdcBitmap, RGB(255, 255, 255));
    28242609        SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2825         PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0, 
     2610        PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    28262611                  (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    28272612#endif
     
    28482633            SetBkColor (hdcBitmap, RGB(255, 255, 255));
    28492634            SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2850             PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0, 
     2635            PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    28512636                      (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    28522637#endif
     
    28632648    /* Update max image count and current image count */
    28642649    himl->cMaxImage = nNewCount;
    2865     if (himl->cCurImage > nCopyCount)
    2866         himl->cCurImage = nCopyCount;
     2650    himl->cCurImage = iImageCount;
    28672651
    28682652    return TRUE;
     
    28712655
    28722656/*************************************************************************
    2873  * ImageList_SetOverlayImage [COMCTL32.82]
     2657 * ImageList_SetOverlayImage [COMCTL32.@]
    28742658 *
    28752659 * Assigns an overlay mask index to an existing image in an image list.
     
    29002684
    29012685
    2902 /* helper for ImageList_Write - write bitmap to pstm 
     2686/* helper for ImageList_Write - write bitmap to pstm
    29032687 * currently everything is written as 24 bit RGB, except masks
    29042688 */
    2905 static BOOL 
     2689static BOOL
    29062690_write_bitmap(HBITMAP hBitmap, LPSTREAM pstm, int cx, int cy)
    29072691{
     
    29182702    xdc = GetDC(0);
    29192703    GetObjectA(hBitmap, sizeof(BITMAP), (LPVOID)&bm);
    2920    
     2704
    29212705    /* XXX is this always correct? */
    29222706    icount = bm.bmWidth / cx;
     
    29602744
    29612745    lpBitsOrg = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, nsizeImage);
    2962     if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg, 
     2746    if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg,
    29632747                  (BITMAPINFO *)bmih, DIB_RGB_COLORS))
    29642748        goto failed;
     
    29672751        int obpl = (((bm.bmWidth*bitCount+31) & ~31)>>3);
    29682752        int nbpl = (((nwidth*bitCount+31) & ~31)>>3);
    2969                
     2753
    29702754        for(i = 0; i < nheight; i++) {
    29712755            int ooff = ((nheight-1-i)%cy) * obpl + ((i/cy) * nbpl);
     
    29742758        }
    29752759    }
    2976    
     2760
    29772761    bmih->biWidth  = nwidth;
    29782762    bmih->biHeight = nheight;
     
    29992783
    30002784/*************************************************************************
    3001  * ImageList_Write [COMCTL32.83]
     2785 * ImageList_Write [COMCTL32.@]
    30022786 *
    30032787 * Writes an image list to a stream.
     
    30522836    return TRUE;
    30532837}
    3054 
Note: See TracChangeset for help on using the changeset viewer.