Changeset 2160 for trunk/src/user32
- Timestamp:
- Dec 20, 1999, 5:45:18 PM (26 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/button.cpp
r2140 r2160 1 /* $Id: button.cpp,v 1.2 2 1999-12-19 17:46:24cbratschi Exp $ */1 /* $Id: button.cpp,v 1.23 1999-12-20 16:45:16 cbratschi Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 797 797 BITMAP bm; 798 798 799 GetIconInfo((HICON)infoPtr->hImage, &iconInfo); 800 GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm); 801 802 imageWidth = bm.bmWidth; 803 imageHeight = bm.bmHeight; 804 805 DeleteObject(iconInfo.hbmColor); 806 DeleteObject(iconInfo.hbmMask); 799 GetIconInfo((HICON)infoPtr->hImage,&iconInfo); 800 if (iconInfo.hbmColor) 801 { 802 GetObjectA(iconInfo.hbmColor,sizeof(BITMAP),&bm); 803 imageWidth = bm.bmWidth; 804 imageHeight = bm.bmHeight; 805 } else 806 { 807 GetObjectA(iconInfo.hbmMask,sizeof(BITMAP),&bm); 808 imageWidth = bm.bmWidth; 809 imageHeight = bm.bmHeight/2; 810 } 811 812 if (iconInfo.hbmColor) DeleteObject(iconInfo.hbmColor); 813 if (iconInfo.hbmMask) DeleteObject(iconInfo.hbmMask); 807 814 808 815 } -
trunk/src/user32/static.cpp
r1810 r2160 1 /* $Id: static.cpp,v 1.1 2 1999-11-22 20:33:24 sandervlExp $ */1 /* $Id: static.cpp,v 1.13 1999-12-20 16:45:16 cbratschi Exp $ */ 2 2 /* 3 3 * Static control … … 91 91 92 92 if (!GetIconInfo(hicon,&ii)) return prevIcon; 93 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); 93 if (ii.hbmColor) 94 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); 95 else 96 { 97 GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp); 98 bmp.bmHeight /= 2; 99 } 94 100 95 101 if (!(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE))) STATIC_ResizeWindow(hwnd,dwStyle,bmp.bmWidth,bmp.bmHeight); 102 103 if (ii.hbmColor) DeleteObject(ii.hbmColor); 104 if (ii.hbmMask) DeleteObject(ii.hbmMask); 96 105 97 106 return prevIcon; … … 679 688 680 689 if (!GetIconInfo(infoPtr->hIcon,&ii)) return; 681 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); 690 if (ii.hbmColor) 691 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); 692 else 693 { 694 GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp); 695 bmp.bmHeight /= 2; 696 } 682 697 DrawIcon(hdc,(rc.right-bmp.bmWidth)/2,(rc.bottom-bmp.bmHeight)/2,infoPtr->hIcon); 698 if (ii.hbmColor) DeleteObject(ii.hbmColor); 699 if (ii.hbmMask) DeleteObject(ii.hbmMask); 683 700 } else if (infoPtr->hIcon) DrawIcon(hdc,rc.left,rc.top,infoPtr->hIcon); 684 701 } -
trunk/src/user32/uitools.cpp
r2093 r2160 1 /* $Id: uitools.cpp,v 1.1 8 1999-12-16 16:53:57cbratschi Exp $ */1 /* $Id: uitools.cpp,v 1.19 1999-12-20 16:45:16 cbratschi Exp $ */ 2 2 /* 3 3 * User Interface Functions … … 1650 1650 1651 1651 if (!GetIconInfo(hIcon,&ii)) return FALSE; 1652 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);1653 1652 oldFg = SetTextColor(hDC,RGB(0,0,0)); 1654 1653 oldBg = SetBkColor(hDC,RGB(255,255,255)); 1655 1654 hMemDC = CreateCompatibleDC(hDC); 1656 1655 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 } 1662 1668 SelectObject(hMemDC,oldBmp); 1663 1669 DeleteObject(hMemDC); 1670 if (ii.hbmColor) DeleteObject(ii.hbmColor); 1671 if (ii.hbmMask) DeleteObject(ii.hbmMask); 1664 1672 SetTextColor(hDC,oldFg); 1665 1673 SetBkColor(hDC,oldBg); … … 1694 1702 1695 1703 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); 1697 1708 1698 1709 /* Calculate the size of the destination image. */ 1699 if ( cxWidth == 0)1710 if (diFlags & DI_DEFAULTSIZE) 1700 1711 { 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) 1707 1715 { 1708 if (diFlags & DI_DEFAULTSIZE)1709 cyWidth = GetSystemMetrics(SM_CYICON);1710 else1711 cyWidth = bmp.bmHeight;1716 cxWidth = bmp.bmWidth; 1717 } else if (cyWidth == 0) 1718 { 1719 cyWidth = ii.hbmColor ? bmp.bmHeight:bmp.bmHeight/2; 1712 1720 } 1713 1721 … … 1729 1737 oldBmp = SelectObject(hMemDC,ii.hbmMask); 1730 1738 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 } 1736 1753 BitBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hBmpDC,0,0,SRCCOPY); 1737 1754 SelectObject(hMemDC,oldBmp); … … 1750 1767 oldBmp = SelectObject(hMemDC,ii.hbmMask); 1751 1768 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 } 1757 1783 SelectObject(hMemDC,oldBmp); 1758 1784 DeleteObject(hMemDC); … … 1761 1787 SetStretchBltMode(hdc,oldStretchMode); 1762 1788 } 1789 if (ii.hbmColor) DeleteObject(ii.hbmColor); 1790 if (ii.hbmMask) DeleteObject(ii.hbmMask); 1763 1791 1764 1792 return TRUE; -
trunk/src/user32/user32.cpp
r2114 r2160 1 /* $Id: user32.cpp,v 1.6 1 1999-12-18 16:31:49cbratschi Exp $ */1 /* $Id: user32.cpp,v 1.62 1999-12-20 16:45:17 cbratschi Exp $ */ 2 2 3 3 /* … … 877 877 break; 878 878 case SPI_GETDRAGFULLWINDOWS: 879 *(BOOL *)pvParam = FALSE; 879 *(BOOL *)pvParam = FALSE; //CB: where is the Warp 4 setting stored? 880 880 break; 881 881 case SPI_GETNONCLIENTMETRICS: … … 912 912 /* from now on we always have an alias for MS Sans Serif */ 913 913 strcpy(lpLogFont->lfFaceName, "MS Sans Serif"); 914 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);914 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", /*8*/12); //CB: 8 is too small 915 915 lpLogFont->lfWidth = 0; 916 916 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; -
trunk/src/user32/winicon.cpp
r1810 r2160 1 /* $Id: winicon.cpp,v 1. 5 1999-11-22 20:33:25 sandervlExp $ */1 /* $Id: winicon.cpp,v 1.6 1999-12-20 16:45:18 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Icon Code for OS/2 … … 70 70 71 71 dprintf(("USER32: CreateIconIndirect\n")); 72 if(pIcon->hbmMask && pIcon->hbmColor) 73 { 74 75 76 77 78 79 80 81 72 if(pIcon->hbmMask && pIcon->hbmColor) 73 { 74 ICONINFO iconinfo; 75 SIZE bmpsize; 76 77 iconinfo = *pIcon; 78 if(GetBitmapDimensionEx(pIcon->hbmColor, &bmpsize) == FALSE) { 79 return 0; 80 } 81 //if there's a color bitmap, the mask bitmap contains only the AND bits 82 82 //Open32 calls WinCreatePointerIndirect which expects AND & XOR bits 83 83 //To solve this we create a bitmap that's 2x height of the mask, copy 84 84 //the AND bits and set the XOR bits to 0 85 86 87 88 89 90 91 85 hdcSrc = CreateCompatibleDC(0); 86 hdcDst = CreateCompatibleDC(0); 87 88 iconinfo.hbmMask = CreateCompatibleBitmap (hdcDst, bmpsize.cx, bmpsize.cy*2); 89 SelectObject (hdcDst, iconinfo.hbmMask); 90 SelectObject (hdcSrc, pIcon->hbmMask); 91 BitBlt (hdcDst, 0, 0, bmpsize.cx, bmpsize.cy, 92 92 hdcSrc, 0, 0, SRCCOPY); 93 94 95 96 97 98 99 100 101 93 PatBlt (hdcDst, bmpsize.cx, bmpsize.cy, bmpsize.cx, bmpsize.cy, BLACKNESS); 94 95 hIcon = O32_CreateIconIndirect(&iconinfo); 96 97 DeleteObject(iconinfo.hbmMask); 98 DeleteDC(hdcSrc); 99 DeleteDC(hdcDst); 100 101 return hIcon; 102 102 } 103 103 hIcon = O32_CreateIconIndirect(pIcon); 104 104 if(hIcon == 0) { 105 105 dprintf(("CreateIconIndirect %d (%d,%d) %x %x failed with %x", pIcon->fIcon, pIcon->xHotspot, pIcon->yHotspot, pIcon->hbmMask, pIcon->hbmColor, GetLastError())); 106 106 } 107 107 return hIcon; … … 115 115 BITMAP bmp; 116 116 117 if(pIcon->hbmMask && pIcon->hbmColor) 118 { 119 120 121 122 123 124 125 117 if(pIcon->hbmMask && pIcon->hbmColor) 118 { 119 ICONINFO iconinfo; 120 HBITMAP hbmOldSrc, hbmOldDst; 121 122 iconinfo = *pIcon; 123 GetObjectA(pIcon->hbmColor, sizeof(BITMAP), (LPVOID)&bmp); 124 125 //if there's a color bitmap, the mask bitmap contains only the AND bits 126 126 //Open32 calls WinCreatePointerIndirect which expects AND & XOR bits 127 127 //To solve this we create a bitmap that's 2x height of the mask, copy 128 128 //the AND bits and set the XOR bits to 0 129 130 131 132 133 134 135 136 StretchBlt(hdcDst, 0, 0, desiredX, desiredY, hdcSrc, 0, 0, 129 hdcSrc = CreateCompatibleDC(0); 130 hdcDst = CreateCompatibleDC(0); 131 132 iconinfo.hbmMask = CreateCompatibleBitmap (hdcDst, desiredX, desiredY*2); 133 hbmOldDst = SelectObject (hdcDst, iconinfo.hbmMask); 134 hbmOldSrc = SelectObject (hdcSrc, pIcon->hbmMask); 135 if(desiredX != bmp.bmWidth || desiredY != bmp.bmHeight) { 136 StretchBlt(hdcDst, 0, 0, desiredX, desiredY, hdcSrc, 0, 0, 137 137 bmp.bmWidth, bmp.bmHeight, SRCCOPY); 138 139 140 141 142 143 144 145 146 147 148 149 StretchBlt(hdcDst, 0, 0, desiredX, desiredY, hdcSrc, 0, 0, 138 } 139 else { 140 BitBlt (hdcDst, 0, 0, bmp.bmWidth, bmp.bmHeight, 141 hdcSrc, 0, 0, SRCCOPY); 142 } 143 PatBlt (hdcDst, desiredX, desiredY, desiredX, desiredY, BLACKNESS); 144 145 if(desiredX != bmp.bmWidth || desiredY != bmp.bmHeight) { 146 iconinfo.hbmColor = CreateCompatibleBitmap (hdcDst, desiredX, desiredY); 147 SelectObject (hdcDst, iconinfo.hbmColor); 148 SelectObject (hdcSrc, pIcon->hbmColor); 149 StretchBlt(hdcDst, 0, 0, desiredX, desiredY, hdcSrc, 0, 0, 150 150 bmp.bmWidth, bmp.bmHeight, SRCCOPY); 151 152 153 154 155 156 157 158 159 160 161 162 163 164 151 } 152 153 hIcon = O32_CreateIconIndirect(&iconinfo); 154 155 DeleteObject(iconinfo.hbmMask); 156 if(desiredX != bmp.bmWidth || desiredY != bmp.bmHeight) { 157 DeleteObject(iconinfo.hbmColor); 158 } 159 SelectObject (hdcDst, hbmOldDst); 160 SelectObject (hdcSrc, hbmOldSrc); 161 DeleteDC(hdcSrc); 162 DeleteDC(hdcDst); 163 164 return hIcon; 165 165 } 166 166 hIcon = O32_CreateIconIndirect(pIcon); 167 167 if(hIcon == 0) { 168 168 dprintf(("CreateIconIndirect %d (%d,%d) %x %x failed with %x", pIcon->fIcon, pIcon->xHotspot, pIcon->yHotspot, pIcon->hbmMask, pIcon->hbmColor, GetLastError())); 169 169 } 170 170 return hIcon; … … 189 189 //In Windows, the mask only contains the AND data if there's a color bitmap 190 190 //--->> We're allocating a bitmap to replace the mask bitmap, but DON'T DELETE it! 191 //WARNING: MEMORY LEAK &DIRTY HACK TO WORK AROUND OPEN32 BUG191 //WARNING: DIRTY HACK TO WORK AROUND OPEN32 BUG 192 192 //****************************************************************************** 193 193 BOOL WIN32API GetIconInfo( HICON hIcon, LPICONINFO pIconInfo) … … 199 199 dprintf(("USER32: GetIconInfo %x", hIcon)); 200 200 rc = O32_GetIconInfo(hIcon, pIconInfo); 201 #if 0 202 if(rc && pIconInfo->hbmColor) 203 { 204 HDC hdcSrc, hdcDst; 205 hdcSrc = CreateCompatibleDC(0); 206 hdcDst = CreateCompatibleDC(0); 207 208 GetObjectA(pIconInfo->hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 209 210 hbmMask = CreateCompatibleBitmap (hdcDst, bmp.bmWidth, bmp.bmHeight/2); 211 hbmOldDst = SelectObject (hdcDst, hbmMask); 212 hbmOldSrc = SelectObject (hdcSrc, pIconInfo->hbmMask); 213 BitBlt (hdcDst, 0, 0, bmp.bmWidth, bmp.bmHeight/2, 214 hdcSrc, 0, bmp.bmHeight/2, SRCCOPY); 215 216 SelectObject(hdcDst, hbmOldDst); 217 SelectObject(hdcSrc, hbmOldSrc); 218 DeleteDC(hdcDst); 219 DeleteDC(hdcSrc); 220 pIconInfo->hbmMask = hbmMask; 201 #if 1 202 if(rc && pIconInfo->hbmColor) 203 { 204 HDC hdcSrc, hdcDst; 205 hdcSrc = CreateCompatibleDC(0); 206 hdcDst = CreateCompatibleDC(0); 207 208 GetObjectA(pIconInfo->hbmColor, sizeof(BITMAP), (LPVOID)&bmp); 209 210 hbmMask = CreateCompatibleBitmap (hdcDst, bmp.bmWidth, bmp.bmHeight); 211 hbmOldDst = SelectObject (hdcDst, hbmMask); 212 hbmOldSrc = SelectObject (hdcSrc, pIconInfo->hbmMask); 213 BitBlt (hdcDst, 0, 0, bmp.bmWidth, bmp.bmHeight, 214 hdcSrc, 0, 0, SRCCOPY); 215 216 SelectObject(hdcDst, hbmOldDst); 217 SelectObject(hdcSrc, hbmOldSrc); 218 DeleteDC(hdcDst); 219 DeleteDC(hdcSrc); 220 DeleteObject(pIconInfo->hbmMask); 221 pIconInfo->hbmMask = hbmMask; 221 222 } 222 223 #endif … … 224 225 } 225 226 /********************************************************************** 226 * 227 * CURSORICON_FindBestIcon 227 228 * 228 229 * Find the icon closest to the requested size and number of colors. … … 231 232 int height, int colors ) 232 233 { 233 int i; 234 int i; 234 235 CURSORICONDIRENTRY *entry, *bestEntry = NULL; 235 236 UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff; … … 248 249 for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++) 249 250 { 250 251 251 iTempXDiff = abs(width - entry->ResInfo.icon.bWidth); 252 iTempYDiff = abs(height - entry->ResInfo.icon.bHeight); 252 253 253 254 if(iTotalDiff > (iTempXDiff + iTempYDiff)) … … 255 256 iXDiff = iTempXDiff; 256 257 iYDiff = iTempYDiff; 257 258 iTotalDiff = iXDiff + iYDiff; 258 259 } 259 260 } … … 279 280 280 281 /********************************************************************** 281 * 282 * CURSORICON_FindBestCursor 282 283 * 283 284 * Find the cursor closest to the requested size. … … 308 309 if ((entry->ResInfo.cursor.wWidth <= width) && (entry->ResInfo.cursor.wHeight <= height) && 309 310 (entry->ResInfo.cursor.wWidth > maxwidth) && (entry->ResInfo.cursor.wHeight > maxheight) && 310 311 (entry->wBitCount == 1)) 311 312 { 312 313 bestEntry = entry; … … 321 322 for(i = 0,entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++) 322 323 if ((entry->ResInfo.cursor.wWidth < maxwidth) && (entry->ResInfo.cursor.wHeight < maxheight) && 323 324 (entry->wBitCount == 1)) 324 325 { 325 326 bestEntry = entry; … … 331 332 } 332 333 /********************************************************************** 333 * LookupIconIdFromDirectoryEx16 334 * LookupIconIdFromDirectoryEx16 (USER.364) 334 335 * 335 336 * FIXME: exact parameter sizes 336 337 */ 337 338 INT WIN32API LookupIconIdFromDirectoryEx(LPBYTE xdir, BOOL bIcon, 338 339 { 340 CURSORICONDIR 339 INT width, INT height, UINT cFlag ) 340 { 341 CURSORICONDIR *dir = (CURSORICONDIR*)xdir; 341 342 UINT retVal = 0; 342 343 … … 344 345 if( dir && !dir->idReserved && (dir->idType & 3) ) 345 346 { 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 347 CURSORICONDIRENTRY* entry; 348 HDC hdc; 349 UINT palEnts; 350 int colors; 351 hdc = GetDC(0); 352 palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL); 353 if (palEnts == 0) 354 palEnts = 256; 355 colors = (cFlag & LR_MONOCHROME) ? 2 : palEnts; 356 357 ReleaseDC(0, hdc); 358 359 if( bIcon ) 360 entry = CURSORICON_FindBestIcon( dir, width, height, colors ); 361 else 362 entry = CURSORICON_FindBestCursor( dir, width, height, 1); 363 364 if( entry ) retVal = entry->wResId; 364 365 } 365 366 else dprintf(("invalid resource directory\n")); … … 367 368 } 368 369 /********************************************************************** 369 * LookupIconIdFromDirectory 370 * LookupIconIdFromDirectory (USER32.379) 370 371 */ 371 372 INT WIN32API LookupIconIdFromDirectory( LPBYTE dir, BOOL bIcon ) 372 373 { 373 return LookupIconIdFromDirectoryEx( dir, bIcon, 374 375 374 return LookupIconIdFromDirectoryEx( dir, bIcon, 375 bIcon ? GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXCURSOR), 376 bIcon ? GetSystemMetrics(SM_CYICON) : GetSystemMetrics(SM_CYCURSOR), bIcon ? 0 : LR_MONOCHROME ); 376 377 } 377 378 /************************************************************************* 378 * CURSORICON_ExtCopy 379 * CURSORICON_ExtCopy 379 380 * 380 381 * Copies an Image from the Cache if LR_COPYFROMRESOURCE is specified 381 382 * 382 383 * PARAMS 383 * Handle [I] handle to an Image 384 * Handle [I] handle to an Image 384 385 * nType [I] Type of Handle (IMAGE_CURSOR | IMAGE_ICON) 385 386 * iDesiredCX [I] The Desired width of the Image … … 395 396 * LR_COPYFROMRESOURCE will only work if the Image is in the Cache. 396 397 * 397 * 398 * 398 399 * TODO: LR_COPYFROMRESOURCE doesn't work. Uses supplied icon instead 399 400 * 400 401 */ 401 HGLOBAL CopyCursorIcon(HGLOBAL Handle, UINT nType, 402 INT iDesiredCX, INT iDesiredCY,403 402 HGLOBAL CopyCursorIcon(HGLOBAL Handle, UINT nType, 403 INT iDesiredCX, INT iDesiredCY, 404 UINT nFlags) 404 405 { 405 406 HGLOBAL hNew=0; … … 408 409 if(Handle == 0) 409 410 { 410 411 return 0; 411 412 } 412 413 … … 414 415 if(!bIsIcon || (nFlags & LR_COPYFROMRESOURCE 415 416 && (iDesiredCX > 0 || iDesiredCY > 0)) 416 || nFlags & LR_MONOCHROME) 417 || nFlags & LR_MONOCHROME) 417 418 { 418 419 LPBYTE pBits; … … 429 430 || (iDesiredCX == 0 && iDesiredCY == 0)) 430 431 { 431 iDesiredCY = GetSystemMetrics(bIsIcon ? 432 iDesiredCY = GetSystemMetrics(bIsIcon ? 432 433 SM_CYICON : SM_CYCURSOR); 433 iDesiredCX = GetSystemMetrics(bIsIcon ? 434 iDesiredCX = GetSystemMetrics(bIsIcon ? 434 435 SM_CXICON : SM_CXCURSOR); 435 436 } 436 437 437 438 /* Create a New Icon with the proper dimension 438 439 */ 439 440 441 440 ICONINFO iconinfo; 441 442 GetIconInfo(Handle, &iconinfo); 442 443 hNew = CreateIconIndirect(&iconinfo, bIsIcon, iDesiredCX, iDesiredCY, nFlags); 443 444 } 444 445 else 445 446 { 446 447 448 449 elsereturn CopyCursor(Handle);447 if(bIsIcon) { 448 return CopyIcon(Handle); 449 } 450 else return CopyCursor(Handle); 450 451 } 451 452 return hNew;
Note:
See TracChangeset
for help on using the changeset viewer.