最近编写了一个需要用到拖放功能的软件,之前本人对其还不神了解,找了网上的一些资料但多说的不是很直接.在这里说说我的心得.
以下所说的拖放功能是急于ole的所以在程序的初始化中确认有如下的语句: 【程序编程相关:C库函数手册】 【推荐阅读:Turbo C 2.0、Borland 】 if (!afxoleinit()) 【扩展信息:[AspProtect]监控网站上传目录】 { return false; } 这个原因费了我很多时间啊 拖放有一个源与一个目的,所以实现的时候需要有两个主要的类:源类coledatasource.目的类coledroptarget. 源的实现必须从coledatasource类派生而来,由于源与目的必须有信息的传送.所以coledatasource提供了几种信息传送方式,这里先介绍一种onrenderfiledata(lpformatetc lpformatetc,cfile* pfile),这个函数是从coledatasource继承下来并实现的.以下是类的源码我的一个例子传送一个文本到目的控件 class cmydatasource : public coledatasource { protected:// attributes
public: // operations public: public: cstring m_strgiffullpath; virtual ~cmydatasource(); cmydatasource();// generated message map functions
protected: virtual bool onrenderfiledata(lpformatetc,cfile*); }; bool cmydatasource::onrenderfiledata(lpformatetc lpformatetc,cfile* pfile) { ... 下一页