Ticket URL: <
http://trac.wxwidgets.org/ticket/14697#comment:2>
#14697: Native drag image support (MSW)
-----------------------------------------------+----------------------------
Reporter: PeterO | Owner:
Type: enhancement | Status: confirmed
Priority: low | Milestone:
Component: wxMSW | Version: 2.9.4
Keywords: dnd drag image native docs-needed | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------+----------------------------
Comment(by PeterO):
Hereby some additional documentation (I don't know exactly where I have to
place this in the comments):
Explanation:
wxDataObject contains the data we want to transfer: text, bitmap etc. To
add data to the data object we use SetData which stores the data in a
specific format. To be able to show a drag image while dragging, even
beyond the borders of our program, the operating system has to store the
image somewhere accessible and in a format known to all clients. Therefore
Windows saves the data image into the data object in a format called
'DragImageBits'. Besides that Windows may save other data in specific
formats for its own housekeeping and extended functionality (eg.
DragSourceHelperFlags, InShellDragLoop, DragContext, IsComputingImage,
IsShowingLayered etc). These formats aren't very well documented.).
So additional to our own SetData calls to set the content data, the
system uses the same SetData to saves its own data. wxDataObject checks if
the format of the data set by SetData is accepted. The Windows formats are
unknown and therefore rejected. But to be able to support the native drag
images we have to accept these formats as well. So if the data hasn't a
format set by the user (the format of the content: text, bitmap etc) we
assume that it's system data and save it in the data object as well. So
now wxDataObject will contain content data (text, bitmap) and system data
(drag image etc). If data is requested from the data object in GetData, a
check is made first if the data is system data else we continue to check
the content formats.
Usage:
To be able to accept drag images (Windows drag images as well, eg.
folder from Explorer) nothing has to be done. wxDropTarget handles all
operations/requests and will show the image.
To be able to create a drag image on starting a drag-drop operation, one
have to call wxDropSource::CreateDragImageFromWindow/Bitmap before calling
DoDragDrop.
Responding to your other questions:
1. dnd sample: The new patch contains a adjusted dnd sample as well. The
window show native window images from outside. Text and shape which will
be dragged from the window will be shown in/outside as well.
1. aux data: The aux data is thus the system data. I've changed the name
'AuxData' to 'SystemData' if that covers the load more clearly.
1. wxDropSourceHelper: I removed it completely. The corresponding
functions in wxDropSource will now do the job.
1. shlobj.h: Has forward declared IDropTargetHelper and moved shlobj.h to
the cpp file.
1. DATASTORAGES: Is called Data now.
1. std::vector<>: Changed to wxVector<>
1. CreateDragImageFromImage: Changed name to CreateDragImageFromBitmap
and accepting now a wxBitmap.
1. CreateDragImageFromWindow: Added window argument.
1. Style consistent: Adjusted but maybe I overlooked something.
--
Ticket URL: <
http://trac.wxwidgets.org/ticket/14697#comment:2>