Skip to content

Instantly share code, notes, and snippets.

@kimkidong
Created September 21, 2012 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimkidong/3761470 to your computer and use it in GitHub Desktop.
Save kimkidong/3761470 to your computer and use it in GitHub Desktop.
[MFC] File Drag&Drop
void Cdrag_and_dropDlg::OnDropFiles(HDROP hDropInfo)
{
LPTSTR pFileName = NULL;
DWORD dwNumDrop = 0,
dwBufSize = 0;
dwNumDrop = DragQueryFile(hDropInfo,0xFFFFFFFF, NULL, 0L);
for (int i = 0 ; i < dwNumDrop ; ++i)
{
// get file name length
dwBufSize = DragQueryFile(hDropInfo,i,NULL,0)+1;
// allocate memory
pFileName = (LPTSTR)new TCHAR[dwBufSize];
// get file name
DragQueryFile(hDropInfo,i,pFileName,dwBufSize);
// add the container(deque)
this->RomFile.push_back(pFileName);
pFileName = NULL;
// show message about drag filename
AfxMessageBox(this->RomFile[i]);
}
CDialogEx::OnDropFiles(hDropInfo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment