CFileDialog appears to truncate offered default file name

  • Thread starter Thread starter rhfritz
  • Start date Start date
R

rhfritz

Guest
I have a dialog which contains a CFileDialog used to export and import a file. This problem exists under Win10 building under vs2017 v15.9.16.

Export looks like this:

CFileDialog saveas_dlg(FALSE, _T(".xml"), csDefaultFilename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, csFilter);
saveas_dlg.m_ofn.lpstrInitialDir = csDefaultFolder;
saveas_dlg.m_ofn.lpstrTitle = "SaveAs - Export";
if(saveas_dlg.DoModal() == IDOK)
{
}


And the dialog appears as expected (cropped for brevity):

1487365.jpg

Import looks like this:

CFileDialog open_dlg(TRUE, _T(".xml"), csDefaultFilename, OFN_FILEMUSTEXIST | OFN_EXPLORER, csFilter);
open_dlg.m_ofn.lpstrInitialDir = csDefaultFolder;
open_dlg.m_ofn.lpstrTitle = "Open - Import";
if (open_dlg.DoModal() == IDOK)
{
}

Note the appearance of the default filename (same as above) in this image (cropped for brevity):

1487373.jpg

As shown, it is displaying the last 15 characters of the filename. If I click anywhere else to change focus the full text appears. I can also click in the edit box and hit the "Home" key to display the text.


The difference in the "SaveAs" case is that there are other controls on the dialog that get created / focus after the edit box. So it would seem that if there was a way to SetFocus() to another control on this dialog before the DoModal, it would probably display correctly. But I suspect this would involve creating a new class derived from CFileDialog.

Also of note is that this is also a very old problem:



CFileDialog truncates offered file name


rhfritz

Continue reading...
 
Back
Top