Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OLE drag/drop bitmap to another app

46 views
Skip to first unread message

loc

unread,
Jan 24, 2002, 3:22:13 PM1/24/02
to
We have an OLE control that we want to implement drag and drop of the image
to any drag and drop container. I have a CBitmap of the image we want to
allow drag and drop on. The question is how do I do this? MSDN indicates
that if I call COleDataSource::CacheGlobalData(CF_BITMAP, hData), hData
should have a handle to the bitmap. I believe Windows store bitmap data in
global memory and the handle in local memory so this kind of make sense.
However, I do not believe handles can be validly copied from one process
space to another so it also doesn't seem right. Any way, the following is
the code I used in my OnMouseMove()

COleDataSource oleDS;
dwBytes = sizeof((HBITMAP)m_pPredrawBitmap);
hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, dwBytes);
BYTE *pDropData = (BYTE *) ::GlobalLock(hData);
::CopyMemory(pDropData, (HBITMAP)m_pPredrawBitmap, dwBytes);
::GlobalUnlock(hData);
oleDS.CacheGlobalData(CF_BITMAP, hData);
dropResult = oleDS.DoDragDrop(DROPEFFECT_COPY);

Does anyone have info on how to do this? Please, no generic drag and drop
sample code. I have other drag and drop working and most samples presents
one way or another that doesn't seem to address this specific problem.

Robert Quirk

unread,
Jan 25, 2002, 6:55:30 AM1/25/02
to
However, I do not believe handles can be validly copied from one process
space to another so it also doesn't seem right.

The OLE subsystem takes care of this for you. If it needs to make a copy it
will.

"loc" <loc.n...@kla-tencor.com> wrote in message
news:uNKJTTRpBHA.1716@tkmsftngp02...

news.microsoft.com

unread,
Jan 25, 2002, 2:43:21 PM1/25/02
to
Well, do you know why the code below does not work? What am I doing wrong?

"Robert Quirk" <robert...@emrad.com> wrote in message
news:1011959627.19672....@news.demon.co.uk...

Robert Quirk

unread,
Jan 29, 2002, 5:15:12 AM1/29/02
to
Don't know. What is m_pDrawBitmap ? If it is a CBitmap * you had better pass

(HBITMAP)m_pDrawBitmap->GetSafeHandle() that is

would you consider casting a CBitmap * to a HBITMAP ? My initial thought is
no .. why should the pointer be equivalent to the wrapped HBITMAP ?

"news.microsoft.com" <loc.n...@kla-tencor.com> wrote in message
news:#2ULOidpBHA.1004@tkmsftngp07...

0 new messages