0

我想用一个CDC,在其中绘制 3 个位图,定位在 中CDC,然后传入UpdateLayeredWindow. 我的问题是无法SIZE* psize正确获取UpdateLayeredWindow函数的参数!任何人都可以帮忙吗?我该怎么办?

BLENDFUNCTION bBlendFnc = {
    AC_SRC_OVER,
    0,
    255,
    AC_SRC_ALPHA
};

CBitmap btCdcBuff;
CBitmap* cache;
BITMAP hbCdcBuff;

btCdcBuff.CreateCompatibleBitmap(pCdcMain, szWndSize.cx, szWndSize.cy); btCdcBuff.GetBitmap(&hbCdcBuff);

cache = pCdcMain->SelectObject(&btCdcBuff); // pCdcMain is a compatible CDC with the screen (pCdcScreen)

Blend(&btIcon); // This function just creates a compatible CDC from a CPaintDC, selects the passed in CBitmap via SelectObject and AlphaBlends it to the pCdcMain.
pCdcMain->SelectObject(cache);

UpdateLayeredWindow(pCdcScreen, NULL, new CSize(hbCdcBuff.bmWidth, hbCdcBuff.bmHeight), pCdcMain, new CPoint(0, 0), 0, &bBlendFnc, ULW_ALPHA) // This fails and returns false
4

1 回答 1

0

将 CreateCompatibleBitmap 与 UpdateLayeredWindow 一起使用时,请确保您传入屏幕的 CDC(即 pCdcScreen 而不是 pCdcMain),以便创建的位图具有正确的格式。看到这个线程:http ://social.msdn.microsoft.com/Forums/en/windowsuidevelopment/thread/1fbcf5e4-b9eb-4537-bf0b-d330aa333fea

于 2012-04-19T16:32:54.883 回答