thanks in advance for your help,
Eduardo
COLORREF cColor;
CBitmap bmAndBack, bmAndObject, bmAndMem, bmWorkCopy;
CBitmap *pOldbmMem, *pOldbmBack, *pOldbmObject, *pOldbmWorkCopy;
CDC hdcMem, hdcBack, hdcObject, hdcWorkCopy;
// Create some DCs to hold temporary data.
hdcBack.CreateCompatibleDC(pdc);
hdcObject.CreateCompatibleDC(pdc);
hdcMem.CreateCompatibleDC(pdc);
hdcWorkCopy.CreateCompatibleDC(pdc);
// Create a bitmap for each DC. DCs are required for a number of GDI
functions.
// Monochrome DC
bmAndBack.CreateBitmap(rcBounds.Width(), rcBounds.Height(), 1, 1, NULL);
// Monochrome DC
bmAndObject.CreateBitmap(rcBounds.Width(), rcBounds.Height(), 1, 1,
NULL);
bmAndMem.CreateCompatibleBitmap(pdc, rcBounds.Width(),
rcBounds.Height());
bmWorkCopy.CreateCompatibleBitmap(&hDC, rcBounds.Width(),
rcBounds.Height());
// Each DC must select a bitmap object to store pixel data.
pOldbmBack = hdcBack.SelectObject(&bmAndBack);
pOldbmObject = hdcObject.SelectObject(&bmAndObject);
pOldbmMem = hdcMem.SelectObject(&bmAndMem);
// Transfer bitmap to working object
pOldbmWorkCopy = hdcWorkCopy.SelectObject(&bmWorkCopy);
hdcWorkCopy.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(), &hDC, 0,
0, SRCCOPY);
// Set the background color of the source DC to the color.
// contained in the parts of the bitmap that should be transparent
cColor = hdcWorkCopy.SetBkColor(cTransparentColor);
// Create the object mask for the bitmap by performing a BitBlt
// from the source bitmap to a monochrome bitmap.
hdcObject.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(),
&hdcWorkCopy, 0, 0, SRCCOPY);
// Set the background color of the source DC back to the original color.
hdcWorkCopy.SetBkColor(hDC.GetBkColor());
// Create the inverse of the object mask.
hdcBack.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(), &hdcObject, 0,
0, NOTSRCCOPY);
// Copy the background of the main DC to the destination.
hdcMem.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(), pdc,
rcBounds.left, rcBounds.top, SRCCOPY);
// Mask out the places where the bitmap will be placed.
hdcMem.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(), &hdcObject, 0,
0, SRCAND);
// Mask out the transparent colored pixels on the bitmap.
hdcWorkCopy.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(), &hdcBack,
0, 0, SRCAND);
// XOR the bitmap with the background on the destination DC.
hdcMem.BitBlt(0, 0, rcBounds.Width(), rcBounds.Height(), &hdcWorkCopy,
0, 0, SRCPAINT);
// Copy the destination to the screen.
pdc->BitBlt(rcBounds.left, rcBounds.top, rcBounds.Width(),
rcBounds.Height(), &hdcMem, 0, 0, SRCCOPY);
hdcBack.SelectObject(pOldbmBack);
hdcObject.SelectObject(pOldbmObject);
hdcMem.SelectObject(pOldbmMem);
hdcWorkCopy.SelectObject(pOldbmWorkCopy);
"Eduardo" <a...@a.com> wrote in message
news:04c701c31307$4c3a3dd0$a101...@phx.gbl...
void DrawTransparentDC(CDC *pdc, CDC &hDC, const CRect& rcBounds, COLORREF
cTransparentColor)
"Tim Magnusssen" <t...@get2net.dk> wrote in message
news:uDVN9mwE...@TK2MSFTNGP11.phx.gbl...