transparent marquee text above bitmap
Hello,
I want to draw a marquee text above a bitmap.
If the background of the text has a solid color:
-----------------------------------------------------------------
void COTextMarq::DrawItem( lpDraw..)
{
HDC hdc = lpDraw->hDC;
BITMAP hBit = ::CreateCompatibleBitmap(
hdc, // handle to DC
w, // width of bitmap, in pixels
h); // height of bitmap, in pixels
HDC hdcM = ::CreateCompatibleDC(hdc);
::SelectObject(hdcM, hBit);
//fill background in hdcM
//draw text in hdcM
::BitBlt(hdc, x, y, w, h, hdcM, 0, 0, SRCCOPY);
}
-----------------------------------------------------------------
To draw transparent,
I take clear bitmap and clear dc and draw the clear background
(I take it from an example):
-----------------------------------------------------------------
void COTextMarq::PaintBk(CDC* pDC)
{
CClientDC clDC(GetParent());
CRect rect;
CRect rect1;
GetClientRect(rect);
GetWindowRect(rect1);
GetParent()->ScreenToClient(rect1);
if (IsWindowVisible())
{
if (m_dcBk.m_hDC == NULL)
{
m_dcBk.CreateCompatibleDC(&clDC);
m_bmpBk.CreateCompatibleBitmap(&clDC, rect.Width(),
rect.Height());
m_pbmpOldBk = m_dcBk.SelectObject(&m_bmpBk);
m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC,
rect1.left, rect1.top, SRCCOPY);
} // if
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0,
SRCCOPY);
}
}
-----------------------------------------------------------------
I call PaintBk in the first part of the DrawItem() function.
But,
this is a little bit slowly and flicker a little bit.
So - I want to opitmize it:
- to draw into m_dcBk in DrawItem(),
then the background is not clear before the new Painting.
Is there a propper way ?
--
Thanks Frank Iversen