默认文件名在Windows IFileDialog中显示为被截断 [英] Default filename appears truncated in Windows IFileDialog

查看:135
本文介绍了默认文件名在Windows IFileDialog中显示为被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Windows IFileDialog界面启动文件浏览器"对话框时,如果提供的默认文件名超过一定数量的字符,我将遇到问题.

When using the Windows IFileDialog interface to launch File browser dialog, I face an issue if the default filename provided exceeds certain number of characters.

文件名看起来被截断了,尽管它只是被包裹起来了,所以我们只能看到最后几个字符.看来问题出在Windows文件浏览器对话框.每当提供的默认文件名超过12-13个字符时,它就会被换行.

The filename appears truncated, although it is simply wrapped around so that we can only see last few characters. It seems the issue lies with the Windows file browser dialog. Whenever the default filename provided exceeds 12-13 characters, it gets wrapped around.

有人遇到过这样的问题吗?有什么解决方法吗?

Has anyone encountered such an issue? Is there any workaround?

操作系统详细信息:
Windows 10版本1709(操作系统内部版本16299.1625)

OS detail:
Windows 10, Version 1709 (OS Build 16299.1625)

对话框快照:

以下共享的代码段:
当单击按钮"BrowseFile"时,就会从MFC应用程序调用此函数.

Code snippet shared below:
This is the function that gets called from an MFC application when a button - "BrowseFile" is clicked.

void CCustomFileBrowserNewDlg::OnBnClickedBrowseFile()
{
    IFileDialog* pfd = nullptr;
    IID id = CLSID_FileSaveDialog;

    const COMDLG_FILTERSPEC c_rgSaveTypes[] =
    {
        {L"Word Document (*.doc)",       L"*.doc"},
        {L"Web Page (*.htm; *.html)",    L"*.htm;*.html"},
        {L"Text Document (*.txt)",       L"*.txt"},
    };


    HRESULT hr = CoCreateInstance(id, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
    if (SUCCEEDED(hr))
    {
        hr = pfd->SetFileTypes(ARRAYSIZE(c_rgSaveTypes), c_rgSaveTypes);
        if (SUCCEEDED(hr))
        {
            hr = pfd->SetFileTypeIndex(1);
            if (SUCCEEDED(hr))
            {
                //pfd->SetFileName(L"Filename.txt");       // This is okay
                pfd->SetFileName(L"SomeLongFilename.txt"); // This name gets wrapped around
                pfd->Show(::GetActiveWindow());
            }
        }

        pfd->Release();
    }
}

推荐答案

示例中的错误很少.您提供的一个示例是保存"对话框,而屏幕截图是打开"对话框.

Few errors in your example. An example that you provided is of save dialog and screenshot is open dialog.

您要讨论的问题将永远不会在保存"对话框中重现,因为过滤器组合框和保存"按钮位于默认文本编辑控件的下一行.

The issue that you are talking about will never reproducible on save dialog because filter combo box and save button are on the next line of default text edit control.

现在,您的问题特定于打开对话框,并且由于同一行中的可用空间较少,默认文本不会向左截断.即,由于文件名静态文本,默认文本编辑控件和过滤器组合框在同一行,因此Windows将此解释为默认文本的可用空间较少,并将文本向左换行.如果将文本光标滚动到文件名静态控件,则将获得完整的文本.您可以向MSDN提出此问题.

Now your problem is specific to open dialog and default text is not truncating its hiding towards left due to less space availability in the same line. i.e. since file name static text, default text edit control and filter combo box are on the same line, windows interpret this as less availability of space for default text and wrap the text towards left. If you scroll text cursor towards file name static control then you will get complete text. You may raise this concern to MSDN.

现在,解决此问题的方法是以最大化模式显示打开文件对话框.一种方法是打开一个对话框,然后将其最大化.接下来的对话框将以最大化模式打开.

Now, a workaround to your problem is to show open file dialog in maximize mode. One way to do this is once a dialog is open then maximize it. Next onwards dialog will open in maximize mode.

这篇关于默认文件名在Windows IFileDialog中显示为被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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