예제 #1
0
BOOL CXTPPopupControl::SetLayeredWindowAttributes(int bAlpha)
{
	if (bAlpha > 255)
		bAlpha = 255;

	if (bAlpha == m_nCurrentTransparency)
		return TRUE;

	m_nCurrentTransparency = bAlpha;

	if (m_pfnSetLayeredWindowAttributes && (GetExStyle() & WS_EX_LAYERED))
	{
		if (m_bLayered)
		{
			BLENDFUNCTION bf;
			bf.BlendOp = AC_SRC_OVER;
			bf.BlendFlags = 0;
			bf.SourceConstantAlpha = (BYTE)bAlpha;
			bf.AlphaFormat = 0x01;
			return m_pfnUpdateLayeredWindow(m_hWnd, (HDC)0, 0, 0, 0, 0, 0, &bf, 0x02);
		}

		//if pointer to transparent func - valid
		return m_pfnSetLayeredWindowAttributes(m_hWnd, 0x00, (BYTE)bAlpha, LWA_ALPHA);
	}


	return FALSE;
}
예제 #2
0
void CXTPPopupControl::SetRegionAlphaLayer(CXTPImageManagerIcon* pIcon)
{
	if (!pIcon)
		return;

	if (!m_pfnUpdateLayeredWindow)
		return;

	CXTPImageManagerIconHandle hShadow;
	hShadow.CopyHandle(pIcon->GetIcon());

	if (!hShadow.PreMultiply())
		return;

	PBYTE pBits = hShadow.PreMultiply();
	CSize szIcon = hShadow.GetExtent();
	int cx = szIcon.cx;
	int cy = szIcon.cy;

	BLENDFUNCTION bf;
	bf.BlendOp = AC_SRC_OVER;
	bf.BlendFlags = 0;
	bf.SourceConstantAlpha = 255;
	bf.AlphaFormat = 0x01;

	POINT pt = {0, 0};

	CClientDC cDC(this);
	CDC dc;
	dc.CreateCompatibleDC(&cDC);

	UINT* pvBits = NULL;

	HBITMAP hBitmap = CXTPImageManager::Create32BPPDIBSection(cDC, cx, cy, (LPBYTE*)&pvBits);

	if (pvBits == NULL || hBitmap == NULL)
		return;

	MEMCPY_S(pvBits,  pBits, cx * cy* 4);

	HBITMAP hOld = (HBITMAP)SelectObject(dc, hBitmap);

	ModifyStyleEx(0, WS_EX_LAYERED);
	m_pfnUpdateLayeredWindow((HWND)GetSafeHwnd(), (HDC)0, 0, &szIcon, dc.GetSafeHdc(), &pt, 0, &bf, 0x02);

	SelectObject(dc, hOld);
	DeleteObject(hBitmap);
	dc.DeleteDC();

	m_bLayered = TRUE;
}
예제 #3
0
int OSSPECFNC::UpdateLayeredWindow( HWND hwnd, HDC hdcDest, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags)
{
	if (m_pfnUpdateLayeredWindow) return m_pfnUpdateLayeredWindow(hwnd,hdcDest,pptDst,psize,hdcSrc, pptSrc, crKey, pblend, dwFlags);
	return 0;
}