Custom drag image not drawing solid
Hello,
I have a customly-drawn drag image showing a small box with some text inside
of it, instead of a normal drag image with either a thumbnail of the
currently dragged image...or a list of the text items being dragged.
Unfortunately, I can't seem to make it solid. It is inherently transparent
and whenever I try taking off the ILC_MASK style or anything else I can think
of...it only shows up black.
Here's the code:
Code Snippet
CRect cRect(0, 0, 22, 22);
// Create bitmap in memory DC
CClientDC cDC(this);
CDC cMemDC;
CBitmap cBitmap;
if (!cMemDC.CreateCompatibleDC(&cDC))
return NULL;
if (!cBitmap.CreateCompatibleBitmap(&cDC, cRect.Width(), cRect.Height()))
return NULL;
CBitmap *pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
CBrush brush;
brush.CreateSolidBrush(RGB(183, 108, 27));
cMemDC.FillRect(cRect, &brush);
CString csCount;
csCount.Format(_T("%d"), GetSelectedCount());
CFont *pOldFont =
cMemDC.SelectObject(&theApp.m_pView->m_pFont[ARIAL_14B]);
cMemDC.SetBkMode(ILD_TRANSPARENT);
cMemDC.SetTextColor(RGB(255, 255, 255));
cMemDC.DrawText(csCount, &cRect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
cMemDC.SelectObject(pOldMemDCBitmap);
CImageList *pNewImageList = new CImageList;
pNewImageList->Create(cRect.Width(), cRect.Height(), ILC_COLOR32 |
ILC_MASK, 0, 1);
pNewImageList->Add(&cBitmap, RGB(0, 0, 0));
cBitmap.DeleteObject();
if (lpPoint)
{
lpPoint->x -= 22;
lpPoint->y -= 22;
}
return pNewImageList;
Any help would be much appreciated. Thanks.
*Note: this is redirected from MSDN forums at
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3335421&SiteID=1
date: Mon, 19 May 2008 04:43:03 -0700
author: cm0101