移动文件并将文件路径显示到编辑框内
This chapter we are study how to get the path of file by using drag drop.
Here is the code, enjoy:
1 void CFileCrcDlg::OnDropFiles(HDROP hDropInfo) 2 { 3 // TODO: Add your message handler code here and/or call default 4 UINT i,iFileCount; 5 char file_name[MAX_PATH]; 6 iFileCount=::DragQueryFile(hDropInfo,0xffffffff,NULL,0); 7 for(i=0;i<iFileCount;i++) 8 { 9 if(i==0) 10 { 11 ::DragQueryFile(hDropInfo,i,file_name,MAX_PATH); 12 SetDlgItemText(IDC_EDIT1_path,file_name); 13 } 14 else 15 { 16 ::DragQueryFile(hDropInfo,i,file_name,MAX_PATH); 17 SetDlgItemText(IDC_EDIT2_crc_hex,file_name); 18 } 19 } 20 ::DragFinish(hDropInfo); 21 CDialog::OnDropFiles(hDropInfo); 22 }
Thank you!