CFileDialog on load prints wrong "Load File..."\

George Yaroshevsky 1 Reputation point
2020-09-04T01:31:10.563+00:00

MFC Visual Studio 2017 Community Update 16..7.2 under Win 10 Home.

Code:
string_t strLoadNetFolder = GetResourceString(IDS_STRING139); // Name of folder
string_t strNetExt = GetResourceString(IDS_STRING140); // Name of file extension "net"
string_t strNetFile = string_t(_T(".")) + strNetExt; // ".net"

  path defLoadNetPath = GetTargetFolderPath(true, strLoadNetFolder);   // Full path

  string_t strFilters(_T("Load Net Files ("));
  strFilters += strNetExt + string_t(_T(" | *.")) + strNetExt + string_t(_T(")")); // net) | *.net || "));

// "Load Net File (net | *.net)

  CFileDialog fileDlg(TRUE, strNetExt.c_str(), strNetFile.c_str(),
    OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER, strFilters.c_str(), this);

  fileDlg.m_ofn.lpstrInitialDir = defLoadNetPath.native().c_str();
  fileDlg.m_ofn.lpstrTitle = _T("Load Image As...");

  if (fileDlg.DoModal() == IDOK)
  {

It displays normal file load dialog, but instead of "Load Net Files *.net it shows "Load Net Files InetO *.net)) and some chinese or japanese tects in drop down submenu. The "Save" dialog with the same code works just fine.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,527 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,181 Reputation points Microsoft Vendor
    2020-09-04T06:46:27.737+00:00

    Hi,

    I suggest you could try to add "||" at the end of the file filter type.

    string_t strFilters(_T("Load Net Files ("));  
       strFilters += strNetExt + string_t(_T(" | *.")) + strNetExt + string_t(_T(")||")); // net) | *.net || "));  
      
    

    Best Regards,

    Jeanine


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments