Re: transparent marquee text above bitmap
I'm not really sure what it is that you are trying to do in the PaintBk
method. Specially the line
CClientDC clDC(GetParent());
But there are a couple of approaches:
One is to take a snapshot of the background before you paint the static
control for the first time. And you use that in your paint method later on.
The other is to invalidate the parent window just under the control before
each time you paint.
CRect Rect;
GetWindowRect(&Rect);
GetParent()->ScreenToClient(&Rect);
GetParent()->InvalidateRect(&Rect);
GetParent()->UpdateWindow();
Both method involve setting the background mode to transparent and setting
the brush to hollow brush in =WM_CTRLCOLOR.
If you want to post more meaningful code then, maybe we can help a little
better.
AliR.
"fiversen" <fiversen@wedding.in-berlin.de> wrote in message
news:ee8535ea-3a83-4c23-aabe-4928d22b7349@p25g2000pri.googlegroups.com...
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