void CWebWindow::_onPaintUpdated(const HDC sourceDC, int x, int y, int cx, int cy) { if (WS_EX_LAYERED == (WS_EX_LAYERED & GetWindowLong(m_hwnd, GWL_EXSTYLE))) { HDC hdc = GetDC(NULL); _paintLayeredDC(hdc, sourceDC); ReleaseDC(NULL, hdc); } else { HDC hdc =GetDC(m_hwnd); _paintDC(hdc, sourceDC); ReleaseDC(m_hwnd, hdc); } if (m_originalPaintUpdatedCallback) m_originalPaintUpdatedCallback(this, m_originalPaintUpdatedCallbackParam, sourceDC, x, y, cx, cy); }
void CWebWindow::_onPaintUpdated(const HDC hdc, int x, int y, int cx, int cy) { if (WS_EX_LAYERED == (WS_EX_LAYERED & GetWindowLong(m_hwnd, GWL_EXSTYLE))) { RECT rectDest; GetWindowRect(m_hwnd, &rectDest); SIZE sizeDest = { rectDest.right - rectDest.left, rectDest.bottom - rectDest.top }; POINT pointDest = { rectDest.left, rectDest.top }; POINT pointSource = { 0, 0 }; HDC hdcScreen = GetDC(NULL); //HDC hdcMemory = CreateCompatibleDC(hdcScreen); //HBITMAP hbmpMemory = CreateCompatibleBitmap(hdcScreen, sizeDest.cx, sizeDest.cy); //HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMemory, hbmpMemory); //BitBlt(hdcMemory, 0, 0, sizeDest.cx, sizeDest.cy, wkeGetViewDC(this), 0, 0, SRCCOPY); BLENDFUNCTION blend = { 0 }; memset(&blend, 0, sizeof(blend)); blend.BlendOp = AC_SRC_OVER; blend.SourceConstantAlpha = 255; blend.AlphaFormat = AC_SRC_ALPHA; UpdateLayeredWindow(m_hwnd, hdcScreen, &pointDest, &sizeDest, (HDC)wkeGetViewDC(this), &pointSource, RGB(0,0,0), &blend, ULW_ALPHA); //SelectObject(hdcMemory, (HGDIOBJ)hbmpOld); //DeleteObject((HGDIOBJ)hbmpMemory); //DeleteDC(hdcMemory); ReleaseDC(NULL, hdcScreen); } else { InvalidateRect(m_hwnd, NULL, FALSE); } if (m_originalPaintUpdatedCallback) m_originalPaintUpdatedCallback(this, m_originalPaintUpdatedCallbackParam, hdc, x, y, cx, cy); }