Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File/folder drag/drop on List control

3 views
Skip to first unread message

Steve

unread,
Jun 10, 2008, 6:07:17 PM6/10/08
to
Hi,
I am using a List control in an MFC application. How do I enable drag &
drop of only files & folder on the List control (set to Report mode)?

Regards,
Steve

Tom Serface

unread,
Jun 10, 2008, 7:10:51 PM6/10/08
to
Here is some code that might help you get started, but basically, you have
an OnDropFiles() function, call DragAcceptFiles() and catch the WM_DROPFILES
message:

http://www.codeguru.com/cpp/controls/listview/dragdrop/article.php/c941/

// In message map
ON_WM_DROPFILES()

// In OnInitDialog()
DragAcceptFiles();

// Handler function
void CAddDataView::OnDropFiles(HDROP hDropInfo)
{
CDialog::OnDropFiles(hDropInfo);
SetForegroundWindow();

for(UINT nThisFile = 0; nThisFile < nFiles; ++nThisFile, ++nIndex) {
TCHAR szFile[_MAX_PATH];
::DragQueryFile(hDropInfo, nThisFile, szFile, _countof(szFile));
DWORD nAttrs;
if((nAttrs = ::GetFileAttributes(szFile)) !=
INVALID_FILE_ATTRIBUTES) {
// Do something with file...
}
}
ResetContent();
::DragFinish(hDropInfo);
}

Tom

"Steve" <st...@sv.sv> wrote in message
news:OhWIaZ0y...@TK2MSFTNGP03.phx.gbl...

0 new messages