Changeset 862
- Timestamp:
- 1/6/2009 8:23:11 AM (4 years ago)
- File:
-
- 1 edited
-
branches/eraser6/ShellExt/CtxMenu.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/ShellExt/CtxMenu.cpp
r861 r862 801 801 return iconInfo.hbmColor; 802 802 803 // Try converting the DDB into a DIB.803 //Draw the icon onto the DIB which will preseve its alpha values 804 804 Handle<HDC> hdcDest = CreateCompatibleDC(NULL); 805 805 HBITMAP dib = CreateDIB(bitmap.bmWidth, bitmap.bmHeight, NULL); 806 806 SelectObject(hdcDest, dib); 807 807 808 typedef HRESULT (__stdcall *pBufferedPaintInit)(void); 809 static HMODULE uxTheme = LoadLibrary(L"UxTheme.dll"); 810 static pBufferedPaintInit BufferedPaintInit = 811 reinterpret_cast<pBufferedPaintInit>(GetProcAddress(uxTheme, "BufferedPaintInit")); 812 if (BufferedPaintInit) 813 { 814 typedef HPAINTBUFFER (_stdcall *pBeginBufferedPaint)(HDC hdcTarget, const RECT* prcTarget, 815 BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdc); 816 typedef HRESULT (__stdcall *pEndBufferedPaint)(HPAINTBUFFER hBufferedPaint, 817 BOOL fUpdateTarget); 818 static pBeginBufferedPaint BeginBufferedPaint = 819 reinterpret_cast<pBeginBufferedPaint>(GetProcAddress(uxTheme, "BeginBufferedPaint")); 820 static pEndBufferedPaint EndBufferedPaint = 821 reinterpret_cast<pEndBufferedPaint>(GetProcAddress(uxTheme, "EndBufferedPaint")); 822 823 BLENDFUNCTION blendFunc = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; 824 BP_PAINTPARAMS paintParams; 825 paintParams.cbSize = sizeof(paintParams); 826 paintParams.dwFlags = BPPF_ERASE; 827 paintParams.prcExclude = NULL; 828 paintParams.pBlendFunction = &blendFunc; 829 830 HDC hdcBuffer; 831 RECT iconRect = { 0, 0, bitmap.bmWidth, bitmap.bmHeight }; 832 HPAINTBUFFER hPaintBuffer = BeginBufferedPaint(hdcDest, &iconRect, BPBF_DIB, 833 &paintParams, &hdcBuffer); 834 835 if (hPaintBuffer) 836 { 837 DrawIconEx(hdcBuffer, 0, 0, icon, bitmap.bmWidth, bitmap.bmHeight, 0, 838 NULL, DI_NORMAL); 839 EndBufferedPaint(hPaintBuffer, TRUE); 840 } 841 } 842 else 843 { 844 DIBSECTION dibSection; 845 if (!GetObject(dib, sizeof(dibSection), &dibSection)) 846 return iconInfo.hbmColor; 847 if (!GetDIBits(hdcDest, iconInfo.hbmColor, 0, bitmap.bmHeight, 848 dibSection.dsBm.bmBits, reinterpret_cast<BITMAPINFO*>(&dibSection.dsBmih), 849 DIB_RGB_COLORS)) 850 return iconInfo.hbmColor; 851 } 852 808 Handle<HBITMAP> iconBitmap(iconInfo.hbmColor); 809 DrawIconEx(hdcDest, 0, 0, icon, bitmap.bmWidth, bitmap.bmHeight, 0, NULL, DI_NORMAL); 853 810 return dib; 854 811 }
Note: See TracChangeset
for help on using the changeset viewer.
