GetOpenFileName changes the setting of setlocale

Giganews Newsgroups
Subject: GetOpenFileName changes the setting of setlocale
Posted by:  Billy the Kid
Date: Wed, 13 Feb 2008

Hello,
we use Visual Studio 2005 UNICODE. We found out that opening a file
selection dialog changes the current local setting. We didnt have this
problem with Visual Studio 2003 non UNICODE.

Code Example:

void C_L10N::TraceLocale(const T_STRING &TraceText)
{
  TRACE_NOCHECK(TraceText << L"Aktuelle Einstellung für locale
" <<
_wsetlocale(LC_ALL, 0));
  TRACE_NOCHECK(L"Aktuelle Einstellung für mbcp
" << _getmbcp());
}

      C_WINTOOL::GetL10N().TraceLocale(L"Vor: Test
");

      CFileDialog  Dialog(TRUE, L"ELE", NULL, OFN_HIDEREADONLY |
OFN_ENABLESIZING | OFN_NOCHANGEDIR, GetDateLine().Str());
      Dialog.m_ofn.lpstrTitle = L"Meiner !!!!";
      Dialog.DoModal();

      C_WINTOOL::GetL10N().TraceLocale(L"Nach: Test
");

Output:

[12:04:40] Vor: Test
Aktuelle Einstellung für locale
LC_COLLATE=C;LC_CTYPE=C;LC_MONETARY=C;LC_NUMERIC=English_United
States.1252;LC_TIME=German_Germany.1252
[12:04:40] Aktuelle Einstellung für mbcp
0
[12:05:11] Nach: Test
Aktuelle Einstellung für locale
German_Germany.1252
[12:05:11] Aktuelle Einstellung für mbcp
0

Why the hell is the settig changed by a SDK call? I changed the code and so
i found out that the setting is okey till i call ::GetOpenFileName()

What can we do to ensure that the Setting we choose for the application is
not changed during runtime?

Replies