Cfiledialog maximum number of multiple files

Source: Internet
Author: User

The cfiledialog class is used to select a file, but for multiple selections, the default maximum number of selected files is limited, and its maximum string buffer size is only 260. In this case, the data member m_ofn needs to be processed, the following code is used:

DWORD nfilenumbers = 500; // maximum number of files selected by cfiledibers filedlg (true, _ T ("TXT"), _ T ("*. TXT "), ofn_filemustexist | ofn_hidereadonly | ofn_allowmultiselect, text (" file (*. TXT) | *. TXT | all files (*. *) | *. * | "), this); position Pos = 0; cstring strfile; tchar * pbufold = filedlg. m_ofn.lpstrfile; // save the old pointer DWORD dwmaxold = filedlg. m_ofn.nmaxfile; // save the old number of filedlg. m_ofn.lpstrfile = new tchar [nfilenumbers * Max_path]; zeromemory (filedlg. m_ofn.lpstrfile, sizeof (tchar) * nfilenumbers * max_path); filedlg. m_ofn.nmaxfile = nfilenumbers * max_path; // The maximum number, which is interpreted as filedlg by msdn. m_ofn.lpstrfile indicates the maximum number of characters in the buffer. // The default value is 260 If (idok! = Filedlg. domodal () goto exit_onbnclickedcreatebatch; Pos = filedlg. getstartposition (); While (POS) {strfile = filedlg. getnextpathname (POS); createlicfilebyeachhardcode (maplicinfo, strfile);} exit_onbnclickedcreatebatch: Delete [] (filedlg. m_ofn.lpstrfile); // clears the filedlg of the heap memory. m_ofn.lpstrfile = pbufold; // restore the previous pointer because it has not gone deep into the source code analysis of cfiledialog. If you do not know whether this is necessary, restore it first,
// Maybe cfiledialog should be used for analysis.
Filedlg. m_ofn.nmaxfile = dwmaxold; // The maximum number before restoration.

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.