问题
I have strange behaviour of CFileDialog once it is opened. The offered file name looks like it has been truncated, so that only last n characters are visible:
image http://ves.fijmovi.com/cpp/CFileDialog_1.jpg
As soon as I click on space for name, I get to see the whole file name:
image http://ves.fijmovi.com/cpp/CFileDialog_2.jpg
So it is not truly truncated, just the beginning position of shown string is not from the start. The complete file name is in this case 36 characters long and part of the string which I get upon opening of dialog is from the 21st character to the last. I tested with some other files which are longer and they also appear truncated, but not from the 21st character, but some other one. I don't see any sense in this.
This piece of code has been several years old:
// Ask user for name and location of the ZIP
CString OfferName = DEFAULT_ZIPFILE_NAME;
CString File_Mask = GetString (IDS_ZIP_SELECT);
CFileDialog fileDlg (TRUE, _T("zip"), OfferName,
OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ENABLESIZING,
File_Mask, pStateThread->GetThreadWindow());
CString strTitleName = GetString (IDS_ARCHIVE_CAPTION);
fileDlg.m_ofn.lpstrTitle = strTitleName;
CString Default_Dir = pConfig->GetTricUserKey (_T("TricSupportDir"));
fileDlg.m_ofn.lpstrInitialDir = Default_Dir;
if (fileDlg.DoModal () != IDOK) {
//..
}
Should I use some special flag for m_ofn? I've read article on MSN about OPENFILENAME structure but I see nothing worth adding to existing flags.
Any thoughts on what might be going on?
回答1:
It happens in all software for me that uses the open file dialog. I think it's just a peculiarity of recent-ish incarnations of that dialog.
来源:https://stackoverflow.com/questions/25210030/cfiledialog-truncates-offered-file-name