CFileDialog 截断提供的文件名 [英] CFileDialog truncates offered file name

查看:56
本文介绍了CFileDialog 截断提供的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦 CFileDialog 打开,我就会有奇怪的行为.提供的文件名看起来已经被截断,因此只有最后 n 个字符可见:

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:

图片 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:

图片 http://ves.fijmovi.com/cpp/CFileDialog_2.jpg

所以它并没有真正被截断,只是显示字符串的开始位置不是从头开始.在这种情况下,完整的文件名有 36 个字符,我在打开对话框时得到的部分字符串是从第 21 个字符到最后一个字符.我用其他一些更长的文件进行了测试,它们也被截断了,但不是从第 21 个字符开始,而是从其他一些字符开始.我认为这没有任何意义.

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) {
        //..
}

我应该为 m_ofn 使用一些特殊的标志吗?我在 MSN 上阅读了关于 OPENFILENAME 结构的文章,但我认为没有什么值得添加到现有标志中的.

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?

推荐答案

它发生在我所有使用打开文件对话框的软件中.我认为这只是该对话最近版本的一个特点.

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.

这篇关于CFileDialog 截断提供的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆