Drag and Drop
ken k.p. pawliw -- pawliw@nortel.ca Monday, June 10, 1996 Environment Visual C++4.0 Windows 95 I'd like to know the procedure required to drop a filename, from a CListView in my application, to the Explorer. Actually, what I really need to know, in my application, is the full pathname of the directory in the Explorer that would be the potential drop source. I have checked through various books, archives, ect. and have not been able to retrieve any information regarding this problem. Any help would be greatly appreciated. Thanks, Ken Pawliw pawliw@bnr.ca
David McGaffin -- dmcgaffi@mail1.videoserver.com Tuesday, June 11, 1996 Ken, Rather than trying to do the whole drop yourself, use OLE drag and drop. I can't cover the whole process in an email message, but you start by deriving a class from IDropSource as shown below. You'll also need to derive a class from IDataObject which provides access to the data type you want to drop (e.g., CF_HDROP). You can use the IDataObject Viewer utility provided with VC 4.0 to view the data types supported by the Explorer. It's not as difficult as it might sound. OLE will do most of the work for you once you've implemented a few member functions in the aforementioned classes. To get a comprehensive description of OLE drag and drop, either go to the related chapter in Brockschmidt or wait until October or so and look for David Platt's _Essence of OLE_ in your favorite bookstore. - David McGaffin dmcgaffin@videoserver.com #includeclass CDropSource : public IDropSource { protected: ULONG m_RefCount ; public: CDropSource(void); ~CDropSource(void); //IDropSource interface members STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); STDMETHODIMP_(ULONG) AddRef(void); STDMETHODIMP_(ULONG) Release(void); STDMETHODIMP QueryContinueDrag(BOOL, DWORD); STDMETHODIMP GiveFeedback(DWORD); }; typedef CDropSource FAR *LPCDropSource; ---------- From: mfc-l[SMTP:mfc-l@netcom.com] Sent: Tuesday, June 11, 1996 5:08 AM To: mfc-l Subject: Drag and Drop Environment Visual C++4.0 Windows 95 I'd like to know the procedure required to drop a filename, from a CListView in my application, to the Explorer. Actually, what I really need to know, in my application, is the full pathname of the directory in the Explorer that would be the potential drop source. I have checked through various books, archives, ect. and have not been able to retrieve any information regarding this problem. Any help would be greatly appreciated. Thanks, Ken Pawliw pawliw@bnr.ca
Wolfgang Loch -- Wolfgang.Loch@RZ.TU-Ilmenau.DE Saturday, June 15, 1996 VC++2.0, NT3.51 >David McGaffin wrote: > > Rather than trying to do the whole drop yourself, use OLE drag and drop. I think, having the same problem like Ken. The only thing we wanna do is to drag files (no OLE objects). Q105530 says: "The supported method for creating a drag and drop server is to use OLE version 2.0." and I'd like to use MFC (not the IDropSource interface) So I want to do something like this: void CFileListBox::OnLButtonDown(..) { COLEDataSource src; // ? put the selected filename to src DROPEFFECT de = src.DoDragDrop(); switch( de ) { : } } The problem is: How can I insert filenames to a COLEDataSource object? Can anyone help ? thanks, Wolfgang.
Neal Stublen -- nstublen@syncro.com Monday, June 24, 1996 An old MSJ article by Jeffrey Richter discusses the undocumented structures used by the Dragxxx API functions and implements a sample dropfile server, allowing the sourcing of drag-and-drop files. I don't know if the method will work under Windows NT 3.51 since this is the method employed by the Windows 3.1 File Manager, but perhaps it's worth a look. The article can be found on MSDN; the article's title is "Drop Everything: How to Make Your Application Accept and Source Drag-and-Drop Files". Sorry, but I'm not sure of the original publication date. >---------- >From: Wolfgang Loch[SMTP:Wolfgang.Loch@RZ.TU-Ilmenau.DE] >Sent: Saturday, June 15, 1996 06:19 AM >To: mfc-l@netcom.com >Subject: Re: Drag and Drop > >VC++2.0, NT3.51 > >>David McGaffin wrote: >> >> Rather than trying to do the whole drop yourself, use OLE drag and drop. > >I think, having the same problem like Ken. >The only thing we wanna do is to drag files (no OLE objects). >Q105530 says: "The supported method for creating a drag and drop server >is to use OLE version 2.0." and I'd like to use MFC (not the >IDropSource >interface) >So I want to do something like this: > >void CFileListBox::OnLButtonDown(..) >{ > COLEDataSource src; > // ? put the selected filename to src > DROPEFFECT de = src.DoDragDrop(); > switch( de ) > { > : > } >} > >The problem is: How can I insert filenames to a COLEDataSource object? >Can anyone help ? >thanks, > Wolfgang. >
Logan Gilbert -- lgilbert@maxserv.com Tuesday, November 19, 1996 Enviroment: VC++4.0, NT4.0, Win95 Hello all. I have a question about drag and drop. I have currently = been working on an OLE control which is used as a part of container = application. This container application uses the component gallery to = insert the OLE control into the application and to create and invoke = methods on the control via the component gallery's control wrap. No = problem. All of this works fine. =20 Now I would like to give my control drag and drop capabilty. From what = I have read in several books (Inside OLE, OLE Controls Inside-Out, = etc...) dragging and dropping text, bitmaps or other forms of data is = fairly straightforward. One creates an OleDataSource object and = provides the data they wish to drag in a specified format. After doing = this one calls DoDragDrop and if there is a Drop Target availiable then = that's all there is to it. What I would like to do is to be able to = drag and drop the entire control. For example I could use this control within a container application and = then drag the control to some other container such as MS Word, Visual = Basic, or Excel. I know that this is possible I just haven't been able = to discover how to do it. I know it is possible since I can Insert this = control in the OLE Control Test Container provided with MSDEV and from = there drag the control and drop it into MS Word, Excel, and the desktop = (by left clicking and dragging on the thin black line surrounding the = control). The test container is doing the drag and drop work for me, = but how? Thank you for any help, Logan Gilbert lgilbert@maxserv.comLogan_Gilbert@msn.com
John and Cecilia -- jandce@iglobal.net Tuesday, January 07, 1997 Environment: MSVC 4.0/Win95 I have an application that uses a list view to display files on a network drive. I would like to be able to drag from the list a file or selection of files to a folder or drive on my computer. I have over-ridden the OnBegindrag() of my view as follows: void View::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; DragFile* drag = new DragFile( CF_TEXT ); //have also tried registered value DROPEFFECT drop = drag->DoDragDrop( DROPEFFECT_COPY|DROPEFFECT_MOVE ); if( drop == DROPEFFECT_COPY ) AfxMessageBox( "Drop copy" ); if( drop == DROPEFFECT_MOVE ) AfxMessageBox( "Drop move" ); delete drag; *pResult = 0; } DragFile is a class derived from COleDataSource. The constructor calls DelayRenderFileData for me. I have passed along CF_TEXT and the CF_* returned from my RegisterFormat() call with the same results. I have also over-ridden the OnRenderFileData() function, in the hopes that I will be able to retreive the file from the remote location and save it to the dropped location. Problem: When I drag to a folder or drive on my computer, I get the circle with a bar (no drop allowed) except for when I am over the trash container. The HEIRSVR sample uses COleServerItem, but it requires that the document be of a type COleDocument. My document is not and does not really need to be. Any ideas on what I could be missing or where else I should look would be greatly appreciated. -- John Boehme jandce@iglobal.net http://www.iglobal.net/pub/JohnAndCe/webmap.htm http://www.iglobal.net/pub/JohnAndCe/ftpcontrol.htm
Mike Blaszczak -- mikeblas@nwlink.com Wednesday, January 08, 1997 At 09:20 1/7/97 -0600, John Boehme wrote: >Environment: MSVC 4.0/Win95 >I have an application that uses a list view to display files on a network >drive. I would like to be able to drag from the list a file or > selection of files to a folder or drive on my computer. >I have over-ridden the OnBegindrag() of my view as follows: Get the AfxMessageBox() calls out of there. They're disrupting the capture and tracking and state of the drag operation. Focus gets switched around and all hell busts loose. .B ekiM http://www.nwlink.com/~mikeblas/ Why does the "new" Corvette look like a 1993 RX-7? These words are my own. I do not speak on behalf of Microsoft.
Tim Philip -- philip@cs.usask.ca Thursday, January 09, 1997 ke Blaszczak writes: At 09:20 1/7/97 -0600, John Boehme wrote: >Environment: MSVC 4.0/Win95 > >I have an application that uses a list view to display files on a network >drive. I would like to be able to drag from the list a file or > selection of files to a folder or drive on my computer. > >I have over-ridden the OnBegindrag() of my view as follows: Change those AfxMessageBox()'s to TRACE0() calls. The dialog boxes are messing up the focus, etc. TRACE calls won't. You can still follow what is going on then. ------- Tim Philip, B.Sc. (Hon) philip@cs.usask.ca Consultant, Graduate Student http://www.cs.usask.ca/grads/philip "... magic has a habit of lying low, like a rake in the grass." - T. Pratchet
| Вернуться в корень Архива |