Which frormat is used for file DRAG to windows explorer ?
-
Which frormat is used for file DRAG to windows explorer ? I need to create drag source for moving files by mouse to Windows Explorer. Which format is used for that? Is ther sample of drag source for that puprose ? thanks.
You need to create CF_HDROP, which is basically a list of file-names, and store it in your data-object. This looks like a long but helpfull article http://www.codeproject.com/shell/explorerdragdrop.asp.
-
You need to create CF_HDROP, which is basically a list of file-names, and store it in your data-object. This looks like a long but helpfull article http://www.codeproject.com/shell/explorerdragdrop.asp.
-
That's what I said. declare a COleDataSource. allocate memory for a CF_HDROP struct + a list of all your file names
hDrop = GlobalAlloc(GMEM_MOVEABLE, bufSize);
lock it:pDrop = (DROPFILES*)GlobalLock(hDrop);
Fill it Unlock and cache it in your data-sourceGlobalUnlock(hgDrop); FORMATETC etc = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; m_dataSrc.CacheGlobalData ( CF_HDROP, hDrop, &etc );
now just call the data-source's DoDragDrop:DROPEFFECT dwEffect = m_dataSrc.DoDragDrop();
and the magic will happen. -
That's what I said. declare a COleDataSource. allocate memory for a CF_HDROP struct + a list of all your file names
hDrop = GlobalAlloc(GMEM_MOVEABLE, bufSize);
lock it:pDrop = (DROPFILES*)GlobalLock(hDrop);
Fill it Unlock and cache it in your data-sourceGlobalUnlock(hgDrop); FORMATETC etc = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; m_dataSrc.CacheGlobalData ( CF_HDROP, hDrop, &etc );
now just call the data-source's DoDragDrop:DROPEFFECT dwEffect = m_dataSrc.DoDragDrop();
and the magic will happen.I think you typed a good code, /thanks/ but some incomplete, after filing that structure - in which function, (which handler) of which class, I can realize begin DRAG operation ? there are many methods to do it, and some are inconsistent with that way, that need be,as first, found. Please point me which method you meant?
-
I think you typed a good code, /thanks/ but some incomplete, after filing that structure - in which function, (which handler) of which class, I can realize begin DRAG operation ? there are many methods to do it, and some are inconsistent with that way, that need be,as first, found. Please point me which method you meant?
I'm abit confused, but here's my word: You will usually want to begin your drag when someone starts dragging items off a list/tree/any-other control. these controls support drag-notifications (LVN_BEGINDRAG for example). At that point, or at any other point you wish to begin your drag, declare your
COleDataSource
on the stack. Then do the actions in the previous message (allocate, fill and cache your CF_HDROP data into the data-source). After this simply calldataObject.DoDragDrop()
and your drag-drop will begin, when it endsdataObject.DoDragDrop
will return. Notice: the destination takes care of performing the operations themselves. So if you're dragging into explorer and drop with a 'copy', explorer will copy the files. -
I'm abit confused, but here's my word: You will usually want to begin your drag when someone starts dragging items off a list/tree/any-other control. these controls support drag-notifications (LVN_BEGINDRAG for example). At that point, or at any other point you wish to begin your drag, declare your
COleDataSource
on the stack. Then do the actions in the previous message (allocate, fill and cache your CF_HDROP data into the data-source). After this simply calldataObject.DoDragDrop()
and your drag-drop will begin, when it endsdataObject.DoDragDrop
will return. Notice: the destination takes care of performing the operations themselves. So if you're dragging into explorer and drop with a 'copy', explorer will copy the files.