Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Mon, 19 May 2008 04:43:03 -0700,    group: microsoft.public.win32.programmer.gdi        back       


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

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us