在 MFC 中的一个设备上下文上绘制多个位图 - winapi



我想使用单个CDC,在其中绘制3个位图,放置在CDC中,然后将其传递到UpdateLayeredWindow中。我的问题是我无法正确获取 UpdateLayeredWindow 函数的SIZE* psize参数!谁能帮忙?我该怎么办?

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

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

最新更新