Combine two icons
-
Hai, I am ving two icon handles, and want to combine them. So that one will be the overlay over the another. I tried with the following code, but it is not displaying properly. Any other solutions? HICON CAutoDocuFileDlg::CombineIcons(HICON topIcon,HICON bottomIcon) {// begin CombineIcons ICONINFO newIcon; newIcon.fIcon = true; HDC screenDC = ::GetDC(NULL); HDC iconDC = CreateCompatibleDC(screenDC); HDC maskDC = CreateCompatibleDC(screenDC); newIcon.hbmColor = CreateCompatibleBitmap(screenDC,16,16); newIcon.hbmMask = CreateCompatibleBitmap(maskDC,16,16); HGDIOBJ oldIconDC = ::SelectObject(iconDC,newIcon.hbmColor); HGDIOBJ oldMaskDC = ::SelectObject(maskDC,newIcon.hbmMask); BitBlt(iconDC,0,0,16,16,NULL,0,0,BLACKNESS); BitBlt(maskDC,0,0,16,16,NULL,0,0,WHITENESS); DrawIconEx(iconDC,0,0,topIcon,16,16,NULL,NULL,DI_ IMAGE); BitBlt(iconDC,0,0,16,16,NULL,0,0,DSTINVERT); // DrawIconEx(maskDC,0,0,topIcon,16,16,NULL,NULL,DI_ MASK); DrawIconEx(iconDC,0,0,bottomIcon,16,16,NULL,NULL, DI_NORMAL); BitBlt(iconDC,0,0,16,16,NULL,0,0,DSTINVERT); DrawIconEx(maskDC,0,0,bottomIcon,16,16,NULL,NULL, DI_MASK); BitBlt(maskDC,0,0,16,16,NULL,0,0,DSTINVERT); ::SelectObject(iconDC,oldIconDC); ::SelectObject(maskDC,oldMaskDC); HICON newFileIcon = CreateIconIndirect(&newIcon); ::ReleaseDC(NULL,screenDC); DeleteDC(maskDC); DeleteDC(iconDC); DeleteObject(newIcon.hbmColor); DeleteObject(newIcon.hbmMask); DeleteObject(oldIconDC); DeleteObject(oldMaskDC); return newFileIcon; }// end CombineIcons