[MFC] 对话框文件拖拽

来源:互联网 发布:com域名 编辑:程序博客网 时间:2024/09/21 06:38

1、对话框Accept Files设置为True

2、对话框添加WM_DROPFILES事件

3、OnDropFiles()实现如下:

void CAntiHashDlg::OnDropFiles(HDROP hDropInfo){int fileNum = DragQueryFile(hDropInfo,-1,NULL,0);for (int i=0; i<fileNum; i++){char filePath[100];DragQueryFile(hDropInfo,i,filePath,100);m_fileList.InsertItem(i,filePath);}DragFinish(hDropInfo);CDialog::OnDropFiles(hDropInfo);}
这里是获取文件路径显示至List Control中

0 0
原创粉丝点击