Implementation of drag and drop function

xiaoxiao2021-03-06  88

Recently, a software that needs to be dragged and dropped. I didn't understand it. I found some information on the Internet but not very straightforward. Tell me here. The drag and drop function said below is rushing to OLE, so confirmed the following statement in the initialization of the program: if (! Afxoleinit ()) {Return False;} I cost me a lot of time a lot of time. Drag and drop with a source and one Objective, there is two main classes when implementing: Source Coledatasource, destination Coledroptarget. The source of the source must be derived from the COLEDATASOSOURCE class, and due to the source of the source and the purpose, there must be information. So ColedataSource provides several information transmission methods, first introducing an onRenderFileData (CFILE * PFILE), which is inherited from COLLDataSource and implemented. The following is a class source code I send a text to the destination control Class CMYDATASOURCE: PUBLIC COLEDASOURCE {Protected:

// attributespublic: // Operationspublic: public: cstring m_strgiffullpath; virtual ~ cmydataroup (); cmydatasource ();

// Generated message map functionsprotected: virtual BOOL OnRenderFileData (LPFORMATETC, CFile *);}; BOOL CMyDataSource :: OnRenderFileData (LPFORMATETC lpFormatEtc, CFile * pFile) {if (lpFormatEtc-> cfFormat == CF_TEXT) {CArchive ar (pFile, CArchive :: store); ar.writestring (m_strgiffullpath); ar << (Byte) '/ 0'; // Note that not to turn off the Ar and Pfile otherwise the destination control cannot accept information return true;}

Coledatasource :: OnRenderFileData (LPFormatetc, Pfile); Return False;

转载请注明原文地址:https://www.9cbs.com/read-96315.html

New Post(0)