MFC Problem on Windows 7

I know this problem is not OpenGL related, but this is the only developer forum i’m signed in, and maybe someone knows how to solve my problem. So, i’m sorry.

Long time ago, I wrote a very simple VRML97 viewer, based on OpenGL and MFC (don’t know the exact version, but it was the one delivered with Visual C++ 6.0). Since then, once in a while I updated it, to now MFC 10 (Visual Studio 2010).

On Windows XP (x86 and x64) every thing works fine. (Don’t know about VISTA) But on Windows 7 only the OpenGL part works as it should work. The main menu, which is supposed to be able to switch language (between german and english) and also should show all VRML light source (for separate activation), stopped working.

Switching language (via SetThreadLocale and destroying and reloading the menu) and all changes to the menu (via AppendMenu/DeleteMenu) stopped working. The menu remains the way it is initially loaded. But no crashes/asserts either.

Maybe a missing update or something. I haven’t found anything on this problem (using Google) yet. MSDN is not very helpful either.

So, thanks for any advice or even hint you could give me.

SOLVED.

I replaced my calls to SetThreadLocale with calls to this little masterpiece:


typedef BOOL (WINAPI* SET_PREFERRED_UI_LANGUAGES_PROTOTYPE) (DWORD, PCWSTR, PULONG);
SET_PREFERRED_UI_LANGUAGES_PROTOTYPE pLangProc=NULL;

void SetThreadLocalSettings(LANGID Language, LANGID SubLanguage)
{
  OSVERSIONINFOEX osver;
  ZeroMemory(&osver, sizeof(osver));
  osver.dwOSVersionInfoSize=sizeof(osver);
  GetVersionEx((OSVERSIONINFO*)&osver);

  if((osver.dwMajorVersion>5))
  {
    if(pLangProc==NULL)
      pLangProc=(SET_PREFERRED_UI_LANGUAGES_PROTOTYPE)GetProcAddress(LoadLibraryA("kernel32"), "SetProcessPreferredUILanguages");

    if(pLangProc)
    { // vista or 2008
      BOOL bResult=FALSE;
      ULONG ulNumOfLangs=1;
      WCHAR wszLanguages[32];
      wsprintfW(wszLanguages, L"%04X%c", MAKELANGID(Language, SubLanguage), 0);

      bResult=pLangProc(0, NULL, &ulNumOfLangs);
      bResult=pLangProc(MUI_LANGUAGE_ID, wszLanguages, &ulNumOfLangs);
    }
    else
    { // fallback for XP
      ::SetThreadLocale(MAKELCID(MAKELANGID(Language, SubLanguage), SORT_DEFAULT));
    }
  }
  else
  { //XP
    ::SetThreadLocale(MAKELCID(MAKELANGID(Language, SubLanguage), SORT_DEFAULT));
  }
}

It solved also my subsequent problems with AppendMenu and DeleteMenu.

Why M$ didn’t point out the problem/change at the appropriate articles in MSDN and KB remains a mystery to me.

So long,
Shinta

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.