Open the file dialog box. If you select multiple files, the order is incorrect.

Source: Internet
Author: User
Use cfiledialog to open multiple files, and then store each file path in an array. A strange appearance may occur. The program is as follows:
Tchar * pszfile = new tchar [max_path * max_path];
Memset (pszfile, 0, sizeof (tchar) * max_path );
Cfiledialog DLG (true, null, null, ofn_hidereadonly | ofn_overwriteprompt | ofn_allowmultiselect | ofn_enablesizing,
_ T ("all files (*. *) | *. * |"), null );
DLG. m_ofn.lpstrfile = pszfile;
DLG. m_ofn.nmaxfile = max_path * max_path;
Csrting filename [1000];
Int numfile;
Numfile = 0;
If (DLG. domodal () = idok)
{
Position Pos = DLG. getstartposition ();
While (Pos! = NULL)
{
Filename [numfile] = DLG. getnextpathname (POS );
Numfile = numfile + 1;
}
}
I open a group of files in the order of 1, 2, 3, 4, 5, 6, and 7.
This occurs when I open a file in the dialog box:
1. If I press Ctrl to select files 1, 2, 3, 4, 5, 6, and 7, the files stored in filename are 7, 1, 2, 3, 4, 5, 6, the last file 7 exists in filename [0], which is not what I want;
2. If I press Ctrl to select the 7, 6, 5, 4, 3, 2, 1 file, and the filename file is saved as 1, 2, 3, 4, 5, 6, 7; this is correct and meets the requirements;
3. If I press the CTR key and use the mouse to frame the selected seven files, the filename is saved as 1, 2, 3, 4, 5, 6, and 7. This is correct and meets the requirements.

File Dialog Box
Getstartposition () always points to the position of the last selected file? How can I make it always point to the beginning of the file list?

To make the file read in a certain order, you can extract all the file paths and sort them in order!

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.