///
// 为对话框增加拖放操作支持
1, 对话框.h中(消息映射表中)
afx_msg void OnDropFiles(HDROP hDropInfo);
2, .cpp中
ON_WM_DROPFILES()
增加函数,函数实现的功能就看各人需要了.
void CLooklogDlg::OnDropFiles(HDROP hDropInfo)
{
// TODO: Add your message handler code here and/or call default
CString filename[1000];//该数组限制了最多只能拖放1000个文件。
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int filecount=DragQueryFile(hDropInfo,0xffffffff,0,0);//取得所拖放的文件数。
for(int i=0;i<min(filecount, 1000);i++)
{
DragQueryFile(hDropInfo,i,filename[i].GetBuffer(512),512);
filename[i].ReleaseBuffer();
}
AfxMessageBox(filename[0]);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CDialog::OnDropFiles(hDropInfo);
}
3, 最后记得在对应对话框的资源属性中, Extended Styles页中, 勾选 Accept Files 的复选框.
OK, 就这么简单的.
转自:http://blog.csdn.net/coolstar14/archive/2007/09/30/1808113.aspx