Ignore:
Timestamp:
Dec 20, 1999, 5:45:18 PM (26 years ago)
Author:
cbratschi
Message:

some icon bug fixes

File:
1 edited

Legend:

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

    r2093 r2160  
    1 /* $Id: uitools.cpp,v 1.18 1999-12-16 16:53:57 cbratschi Exp $ */
     1/* $Id: uitools.cpp,v 1.19 1999-12-20 16:45:16 cbratschi Exp $ */
    22/*
    33 * User Interface Functions
     
    16501650
    16511651  if (!GetIconInfo(hIcon,&ii)) return FALSE;
    1652   GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
    16531652  oldFg = SetTextColor(hDC,RGB(0,0,0));
    16541653  oldBg = SetBkColor(hDC,RGB(255,255,255));
    16551654  hMemDC = CreateCompatibleDC(hDC);
    16561655  oldBmp = SelectObject(hMemDC,ii.hbmMask);
    1657   BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCAND);
    1658   SelectObject(hMemDC,ii.hbmColor);
    1659   BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCPAINT);
    1660   SelectObject(hMemDC,ii.hbmMask);
    1661   BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,bmp.bmHeight,SRCINVERT);
     1656  if (ii.hbmColor)
     1657  {
     1658    GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     1659    BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCAND);
     1660    SelectObject(hMemDC,ii.hbmColor);
     1661    BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCINVERT);
     1662  } else
     1663  {
     1664    GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp);
     1665    BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight/2,hMemDC,0,0,SRCAND);
     1666    BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight/2,hMemDC,0,bmp.bmHeight/2,SRCINVERT);
     1667  }
    16621668  SelectObject(hMemDC,oldBmp);
    16631669  DeleteObject(hMemDC);
     1670  if (ii.hbmColor) DeleteObject(ii.hbmColor);
     1671  if (ii.hbmMask) DeleteObject(ii.hbmMask);
    16641672  SetTextColor(hDC,oldFg);
    16651673  SetBkColor(hDC,oldBg);
     
    16941702
    16951703  if (!GetIconInfo(hIcon,&ii)) return FALSE;
    1696   GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     1704  if (ii.hbmColor)
     1705    GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     1706  else
     1707    GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp);
    16971708
    16981709  /* Calculate the size of the destination image.  */
    1699   if (cxWidth == 0)
     1710  if (diFlags & DI_DEFAULTSIZE)
    17001711  {
    1701     if (diFlags & DI_DEFAULTSIZE)
    1702       cxWidth = GetSystemMetrics(SM_CXICON);
    1703     else
    1704       cxWidth = bmp.bmWidth;
    1705   }
    1706   if (cyWidth == 0)
     1712    cxWidth = GetSystemMetrics(SM_CXICON);
     1713    cyWidth = GetSystemMetrics(SM_CYICON);
     1714  } else if (cxWidth == 0)
    17071715  {
    1708     if (diFlags & DI_DEFAULTSIZE)
    1709       cyWidth = GetSystemMetrics(SM_CYICON);
    1710     else
    1711       cyWidth = bmp.bmHeight;
     1716    cxWidth = bmp.bmWidth;
     1717  } else if (cyWidth == 0)
     1718  {
     1719    cyWidth = ii.hbmColor ? bmp.bmHeight:bmp.bmHeight/2;
    17121720  }
    17131721
     
    17291737    oldBmp = SelectObject(hMemDC,ii.hbmMask);
    17301738    oldStretchMode = SetStretchBltMode(hBmpDC,STRETCH_DELETESCANS);
    1731     StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
    1732     SelectObject(hMemDC,ii.hbmColor);
    1733     StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCPAINT);
    1734     SelectObject(hMemDC,ii.hbmMask);
    1735     StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
     1739    if (ii.hbmColor)
     1740    {
     1741      if (diFlags & DI_MASK)
     1742        StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
     1743      if (diFlags & DI_IMAGE)
     1744      {
     1745        SelectObject(hMemDC,ii.hbmColor);
     1746        StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
     1747      }
     1748    } else if (diFlags & DI_MASK)
     1749    {
     1750      StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight/2,SRCAND);
     1751      StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight/2,bmp.bmWidth,bmp.bmHeight/2,SRCINVERT);
     1752    }
    17361753    BitBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hBmpDC,0,0,SRCCOPY);
    17371754    SelectObject(hMemDC,oldBmp);
     
    17501767    oldBmp = SelectObject(hMemDC,ii.hbmMask);
    17511768    oldStretchMode = SetStretchBltMode(hdc,STRETCH_DELETESCANS);
    1752     StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
    1753     SelectObject(hMemDC,ii.hbmColor);
    1754     StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCPAINT);
    1755     SelectObject(hMemDC,ii.hbmMask);
    1756     StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
     1769    if (ii.hbmColor)
     1770    {
     1771      if (diFlags & DI_MASK)
     1772        StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
     1773      if (diFlags & DI_IMAGE)
     1774      {
     1775        SelectObject(hMemDC,ii.hbmColor);
     1776        StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
     1777      }
     1778    } else if (diFlags & DI_MASK)
     1779    {
     1780      StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
     1781      StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight/2,bmp.bmWidth,bmp.bmHeight/2,SRCINVERT);
     1782    }
    17571783    SelectObject(hMemDC,oldBmp);
    17581784    DeleteObject(hMemDC);
     
    17611787    SetStretchBltMode(hdc,oldStretchMode);
    17621788  }
     1789  if (ii.hbmColor) DeleteObject(ii.hbmColor);
     1790  if (ii.hbmMask) DeleteObject(ii.hbmMask);
    17631791
    17641792  return TRUE;
Note: See TracChangeset for help on using the changeset viewer.