帮我解释一下 下面的代码的含义?每一行都说明一下 30

其中CMyOleDataSource是COleDataSource的派生类CMyOleDataSource*pods=newCMyOleDataSource();pOle... 其中CMyOleDataSource 是COleDataSource 的派生类
CMyOleDataSource* pods = new CMyOleDataSource();
pOleDataSource = pods;
UINT uFileCount = m_fileList.GetSelectedCount();
UINT uBuffSize = sizeof(FILEGROUPDESCRIPTOR) +
(uFileCount-1) * sizeof(FILEDESCRIPTOR);
hFileDescriptor = GlobalAlloc (
GHND | GMEM_SHARE, uBuffSize );
if(hFileDescriptor)
{
FILEGROUPDESCRIPTOR* pGroupDescriptor =
(FILEGROUPDESCRIPTOR*) GlobalLock ( hFileDescriptor );
if(pGroupDescriptor)
{
FILEDESCRIPTOR* pFileDescriptorArray =
(FILEDESCRIPTOR*)((LPBYTE)pGroupDescriptor + sizeof(UINT));
pGroupDescriptor->cItems = uFileCount;

POSITION pos = m_fileList.GetFirstSelectedItemPosition();

TRACE("pos%d",pos);
int index = 0;
pods->m_Files.RemoveAll();
while( NULL != pos )
{
int nSelItem = m_fileList.GetNextSelectedItem( pos );
TRACE("nSelItem%d",nSelItem);
ZeroMemory(&pFileDescriptorArray[index],
sizeof(FILEDESCRIPTOR));
lstrcpy ( pFileDescriptorArray[index].cFileName,
m_fileList.GetItemText( nSelItem, 0 ) );
pods->m_Files.Add(pFileDescriptorArray[index].cFileName);
pFileDescriptorArray[index].dwFlags = FD_FILESIZE|FD_ATTRIBUTES;
pFileDescriptorArray[index].nFileSizeLow = 512;
pFileDescriptorArray[index].nFileSizeHigh = 0;
pFileDescriptorArray[index].dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
index++;
}
}
else
{
GlobalFree ( hFileDescriptor );
}
}
GlobalUnlock ( hFileDescriptor );

FORMATETC etcDescriptor = {
RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR),
NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
pods->CacheGlobalData ( RegisterClipboardFormat(
CFSTR_FILEDESCRIPTOR), hFileDescriptor, &etcDescriptor );

FORMATETC etcContents = {
RegisterClipboardFormat(CFSTR_FILECONTENTS),
NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
pods->DelayRenderFileData(RegisterClipboardFormat(
CFSTR_FILECONTENTS), &etcContents);

pods->SetClipboard();
/////////////////////////////////////////////////////////////
下面是CMyOleDataSource类的定义
// MyOleDataSource.h: interface for the CMyOleDataSource class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYOLEDATASOURCE_H__B23F9B80_7A52_4CDD_8B01_D31D506D0B74__INCLUDED_)
#define AFX_MYOLEDATASOURCE_H__B23F9B80_7A52_4CDD_8B01_D31D506D0B74__INCLUDED_
#include<afxole.h>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMyOleDataSource: public COleDataSource
{
public:
CStringArray m_Files;
CMyOleDataSource();
virtual ~CMyOleDataSource();
virtual BOOL OnRenderFileData(
LPFORMATETC lpFormatEtc,CFile* pFile);

};

#endif // !defined(AFX_MYOLEDATASOURCE_H__B23F9B80_7A52_4CDD_8B01_D31D506D0B74__INCLUDED_)
#include "MyOleDataSource.h"

// Construction/Destruction

BOOL CMyOleDataSource::OnRenderFileData(LPFORMATETC lpFormatEtc,CFile* pFile)
{

if(lpFormatEtc->cfFormat ==
RegisterClipboardFormat(CFSTR_FILECONTENTS))
{
HGLOBAL hGlob = NULL;
const int buffSize = 512;
hGlob = GlobalAlloc(GMEM_FIXED, buffSize);
if(hGlob)
{
LPBYTE pBytes = (LPBYTE)GlobalLock(hGlob);
if(pBytes)
{
memset(pBytes, (int) m_Files.GetAt(
lpFormatEtc->lindex)[0], buffSize);
pFile->Write(pBytes,buffSize);
}
GlobalUnlock(hGlob);
}
GlobalFree(hGlob);
return TRUE;
}

// COleDataSource::DoDragDrop(DROPEFFECT_COPY | DROPEFFECT_MOVE);

return COleDataSource::OnRenderFileData(lpFormatEtc,pFile);

}
这是类CMyOleDataSource的实现文件
说的好的,我可以加分200,知道里没有什么高手呀!!!
展开
 我来答
百度网友98837d0
2006-10-21 · TA获得超过207个赞
知道小有建树答主
回答量:307
采纳率:0%
帮助的人:283万
展开全部
每一行都说明一下。~?~
`

``你想累死人啊。`>
`
`还只有30分.~
`
`
``找力工去吧.~
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式