Ignore:
Timestamp:
Nov 3, 1999, 8:51:44 PM (26 years ago)
Author:
sandervl
Message:

mouse activate + CreateIconIndirect fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/winicon.cpp

    r949 r1576  
    1 /* $Id: winicon.cpp,v 1.1 1999-09-15 23:19:03 sandervl Exp $ */
     1/* $Id: winicon.cpp,v 1.2 1999-11-03 19:51:44 sandervl Exp $ */
    22/*
    33 * Win32 Icon Code for OS/2
     
    5555//******************************************************************************
    5656//******************************************************************************
    57 HICON WIN32API CreateIconIndirect(LPICONINFO arg1)
     57HICON WIN32API CreateIconIndirect(LPICONINFO pIcon)
    5858{
    59 #ifdef DEBUG
    60     WriteLog("USER32:  CreateIconIndirect\n");
    61 #endif
    62     return O32_CreateIconIndirect(arg1);
     59 HICON   hIcon;
     60 HDC     hdcSrc, hdcDst;
     61
     62    dprintf(("USER32:  CreateIconIndirect\n"));
     63    if(pIcon->hbmMask && pIcon->hbmColor)
     64    {
     65        ICONINFO iconinfo;
     66        SIZE bmpsize;
     67
     68        iconinfo = *pIcon;
     69        if(GetBitmapDimensionEx(pIcon->hbmColor, &bmpsize) == FALSE) {
     70                return 0;
     71        }
     72        //if there's a color bitmap, the mask bitmap contains only the AND bits
     73        //Open32 calls WinCreatePointerIndirect which expects AND & XOR bits
     74        //To solve this we create a bitmap that's 2x height of the mask, copy
     75        //the AND bits and set the XOR bits to 0
     76        hdcSrc = CreateCompatibleDC(0);
     77        hdcDst = CreateCompatibleDC(0);
     78
     79        iconinfo.hbmMask  = CreateCompatibleBitmap (hdcDst, bmpsize.cx, bmpsize.cy*2);
     80        SelectObject (hdcDst, iconinfo.hbmMask);
     81        SelectObject (hdcSrc, pIcon->hbmMask);
     82        BitBlt (hdcDst, 0, 0, bmpsize.cx, bmpsize.cy,
     83                hdcSrc, bmpsize.cx, 0, SRCCOPY);
     84        PatBlt (hdcDst, bmpsize.cx, bmpsize.cy, bmpsize.cx, bmpsize.cy, BLACKNESS);
     85       
     86        hIcon = O32_CreateIconIndirect(&iconinfo);
     87
     88        DeleteObject(iconinfo.hbmMask);
     89        DeleteDC(hdcSrc);
     90        DeleteDC(hdcDst);
     91
     92        return hIcon;
     93    }
     94    hIcon = O32_CreateIconIndirect(pIcon);
     95    if(hIcon == 0) {
     96        dprintf(("CreateIconIndirect %d (%d,%d) %x %x failed with %x", pIcon->fIcon, pIcon->xHotspot, pIcon->yHotspot, pIcon->hbmMask, pIcon->hbmColor, GetLastError()));
     97    }
     98    return hIcon;
    6399}
    64100//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.