Dropfile implementation code snippet

Source: Internet
Author: User
Tags dropfile

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
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.