The following is my simple implementation ..
I created an mfc project .. The Interface contains a listbox .. Member variable: m_list.
Add: this-> DragAcceptFiles (TRUE) in OnInitDialog );
Add a WM_DROPFILES message to this dialog box ..
Message Processing functions:
Void CdrayFilesDlg: OnDropFiles (HDROP hDropInfo) {// TODO: add the message processing program code and/or call the default UINT uFileNum =: DragQueryFile (hDropInfo, 0 xffffffffff, NULL, 0); WCHAR strFileName [MAX_PATH]; for (int I = 0; I <uFileNum; I ++) {: DragQueryFileW (hDropInfo, I, strFileName, MAX_PATH ); CString str (strFileName); m_list.AddString (str + "\ r \ n"); }:: DragFinish (hDropInfo); CDialogEx: OnDropFiles (hDropInfo);} void CdrayFilesDlg :: onDropFiles (HDROP hDropInfo) {// TODO: add the message processing program code here and/or call the default UINT uFileNum =: DragQueryFile (hDropInfo, 0 xffffffff, NULL, 0 ); WCHAR strFileName [MAX_PATH]; for (int I = 0; I <uFileNum; I ++) {: DragQueryFileW (hDropInfo, I, strFileName, MAX_PATH ); CString str (strFileName); m_list.AddString (str + "\ r \ n"); }:: DragFinish (hDropInfo); CDialogEx: OnDropFiles (hDropInfo );}
In this way, you can implement the drag function .. I didn't expect it to be that simple ..