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!