1. First, set your cdialog to accept files.
2. Add function declaration and message ing
// Add the event Declaration (try to write it out of the "afx_msg" macro. I remember that there will be an error in it)
Afx_msg void ondropfiles (hdrop hdropinfo );
// Add message ing (try to write it out of the "afx_msg_map" macro. I remember that an error will occur when writing it in it)
On_wm_dropfiles ()
3. The next step is to implement the function.
// Implementation (Windows supports dragging and dropping multiple files at the same time)
Void cmydlg: ondropfiles (hdrop hdropinfo)
{
Uint cfiles =: dragqueryfile (hdropinfo, 0 xffffffff, 0, 0); // obtain the number of files
Cstring sztext;
Char szfile [max_path];
For (uint COUNT = 0; count <cfiles; count ++)
{
If (cfiles> 0)
{
: Dragqueryfile (hdropinfo, Count, szfile, sizeof (szfile ));
Sztext + = szfile; // absolute path + file name stored in szfile
Sztext + = "/R/N"; // retrieve all the files to sztext, one row
// Break; // only obtain the first file
}
}
// Corresponding operation
}