我欲乘风yecheng.blog.chinaunix.net
yecheng_110
全部博文(78)
2007年(53)
2006年(25)
DT27
jolinok
ylke2007
saintdra
zhxd
大鬼不动
tntcheng
chenkeac
flb_2001
yyfq521
bluesky0
zjq5688
w1818618
168Kill
myoeoo
bolebdms
sxzf168
11qq22ww
分类:
2007-03-24 15:51:32
//IDropTarget的Drop中实现STDMETHODIMP Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect){ HRESULT hr; STGMEDIUM stgMedium; FORMATETC cFmt; UINT CF_URL; UINT CF_HTML; CF_URL = RegisterClipboardFormat(CFSTR_SHELLURL); CF_HTML = RegisterClipboardFormat(_T("HTML Format")); //HTML cFmt.lindex = -1; cFmt.cfFormat = CF_HTML; cFmt.ptd = 0; cFmt.dwAspect = 1; cFmt.tymed = TYMED_HGLOBAL; hr = pDataObject->GetData(&cFmt, &stgMedium); if(SUCCEEDED(hr)) { char *utf = (CHAR*)(stgMedium.hGlobal);//utf8编码 //.......... ::ReleaseStgMedium(&stgMedium); return S_OK; } //URL cFmt.lindex = -1; cFmt.cfFormat = CF_URL; cFmt.ptd = 0; cFmt.dwAspect = 1; cFmt.tymed = TYMED_HGLOBAL; hr = pDataObject->GetData(&cFmt, &stgMedium); if(SUCCEEDED(hr)) { char *url = (char*)(stgMedium.hGlobal)//ascii编程 //......... ::ReleaseStgMedium(&stgMedium); return S_OK; } //FILE. cFmt.lindex = -1; cFmt.cfFormat = CF_HDROP; cFmt.ptd = 0; cFmt.dwAspect = 1; cFmt.tymed = TYMED_HGLOBAL; hr = pDataObject->GetData(&cFmt, &stgMedium); if(SUCCEEDED(hr)) { HDROP hDrop; hDrop = (HDROP)(stgMedium.hGlobal); UINT iFiles,ich =0; TCHAR Buffer[MAX_PATH] = _T(""); memset(&iFiles,0xff,sizeof(iFiles)); //Get the Drag _Files Number. int Count = ::DragQueryFile(hDrop,iFiles,Buffer,0); if(Count) { for (int i=0;i<Count;i++) { if(::DragQueryFile(hDrop,i,Buffer,sizeof(Buffer))) { //File name is in Buffer now. //........... } } } //................. ::DragFinish(hDrop); ::ReleaseStgMedium(&stgMedium); return S_OK; } return E_FAILED;}
上一篇:IE7中激活的tab
下一篇:MSHTML的DOM模型
登录 注册