|
-
April 27th, 1999, 03:52 AM
#1
How to drag files out from ListViewCtrl
Hi,
I want to drop files listed in my listview control
out onto Desktop Explorer.
When Drag begins,
following codes run.
Hmm... Dragging is OK,
But after drop, there is no further action.
What I want to do is,
Drag files outof my list control and
copy them into the folder I selected by
dragging.
I used COleDataSource class instead of
using COM API "DoDraDrop" directly.
void CTestDlg::OnBegindragList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
COleDataSource cods;
COleDropSource dropsource;
STGMEDIUM stgmedium;
FORMATETC formatetc;
DROPEFFECT de;
CString str;
str = "C:\\Autoexec.bat";
/*
formatetc.tymed = TYMED_FILE;
formatetc.cfFormat = CF_HDROP;
formatetc.dwAspect = DVASPECT_ICON;
formatetc.lindex = 0;
formatetc.ptd = NULL;
*/
HGLOBAL h;
h = GlobalAlloc(GHND|GMEM_SHARE, str.GetLength()+1);
strcpy( LPSTR(GlobalLock(h)), "C:\\Autoexec.bat");
GlobalUnlock(h);
cods.CacheGlobalData(CF_HDROP, h, &formatetc);
/*
stgmedium.tymed = TYMED_FILE;
stgmedium.lpszFileName = (unsigned short*)(L"C:\\Autoexec.bat");
stgmedium.pUnkForRelease = NULL;
*/
de = cods.DoDragDrop(DROPEFFECT_COPY | DROPEFFECT_MOVE);
if( de ==DROPEFFECT_MOVE )
{
AfxMessageBox("Drop Move");
}
else if( de == DROPEFFECT_COPY )
{
AfxMessageBox("Drop Copy");
}
else
{
AfxMessageBox("Drop NONE");
}
GlobalFree(h);
*pResult = 0;
}
What can I do?
Please help.......
http://www.jiran.com/~jijon"[img]htt....gif[/img]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|