Drag & Drop Shell items / stream format with VB's DataObject
- From: "OrlandoCurioso" <rw@xxxxxxxxxxxxxxxxx>
- Date: 12 Jun 2005 09:20:44 -0700
Problem: Setting up an stream format with VB's DataObject.
Scenario:
Drag & Drop of shell items in SysTree32, wrapped in an usercontrol,
using IShellFolder,IDataObject,IDropTarget COM interfaces.
Operation (acting as drop target):
In the UC_OLEDragOver event (state = vbEnter) I get the IDataObject of
dragged items from VB's DataObject by Edanmo's black magic:
(http://www.mvps.org/emorcillo/en/code/vb6/getidataobject.shtml)
CopyMemory ido, ByVal ObjPtr(Data) + 16, 4&
In sucessive _OLEDragOver, OLEDragDrop I retrieve the IDropTarget of
the drop node and call IDropTarget.DragEnter etc methods passing the
IDataObject.
This works flawless , including the drag image provided by
IDropTargetHelper.
Operation (acting as drop source):
Normally you would implement an IDropSource as a public class with
QueryContinueDrag() and GiveFeedback() and call the DoDragDrop API.
This I want to avoid, since it would limit using the usercontrol in a
compiled ocx or ActiveExe project.
So I get the IDataObject of dragged items by ISF.GetUIObjectOf(),
enumerate it's contents with IEnumFORMATETC, copy content of a format
to a bytearray and populate VB's DataObject with it. So the shell
provides me with all needed formats,
especially the difficult CFSTR_SHELLIDLIST.
Sucessive _OLEDragOver, OLEDragDrop events like above.
I create the drag image by IDragSourceHelper.InitializeFromBitmap().
Dragging in- or outside is fine, but drag image only shows up in my
tree, not in other (explorer) app.
IDragSourceHelper,IDropTargetHelper use two internal (thus
undocumented) formats:
CFSTR_DRAGBITS uses global memory (TYMED_HGLOBAL) and is copied to my
VB.DataObject.
CFSTR_DRAGCONTEXT is a simple 16 bytes stream (TYMED_ISTREAM) and I
don't know how to copy it.
Possible solutions:
I suspect the missing CFSTR_DRAGCONTEXT format causes the missing
image, so
- Can VB.DataObject handle somehow stream formats?
VB's DataObject wraps an IDataObject, so I tried to exchange the
original with a pointer to the IDataObject, obtained from shell.
-> no luck. Any clues, hints or documentation, how VB's DataObject
works internally?
The UserControl must have an IDropSource implementation.
- Does anyone posess black magic, howto obtain a reference ?
All the ones, I can't think of:
- Your turn, please!
PS:
I published the treeview usercontrol on PSC:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?
txtCodeId=59769&lngWId=1
A set of helper classes & modules turning it into an
Explorer alike tree, i will publish too,
when you hopefully solved my last problem.
.
- Follow-Ups:
- Drag & Drop Shell items / stream format with VB's DataObject
- From: OrlandoCurioso
- Re: Drag & Drop Shell items / stream format with VB's DataObject
- From: Sam Hobbs
- Drag & Drop Shell items / stream format with VB's DataObject
- Prev by Date: Re: FtpSetCurrentDirectory or other
- Next by Date: Re: How to get a handle to an active word document for use in Word VBA
- Previous by thread: VB2005? What did they fix?
- Next by thread: Re: Drag & Drop Shell items / stream format with VB's DataObject
- Index(es):
Relevant Pages
|