CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Language

  1. #1
    Join Date
    May 2002
    Location
    Germany
    Posts
    487

    Language

    OK,
    I have two recources, german and english in one *.rc file. The application chooses depending on the windows version, which languge to take. But now I want to test my changed english texts on my german windows? What do I need to do?

    Thanks!

    Marc

  2. #2
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,895
    The most common way of doing this is compile the 2 resources in to 2 dlls. and use AfxSetResourceHandle to set your language specific resource.

    [ccode]
    HINSTANCE hCurInstanceRes = LoadLibrary("yourGermanResource.dll");

    if(m_hCurInstanceRes)
    {
    // Set as resource library
    AfxSetResourceHandle(m_hCurInstanceRes);
    }
    [/ccode]

  3. #3
    Join Date
    Sep 2002
    Posts
    77
    Another solution is to call SetThreadLocale at application startup (for example in InitInstance).
    This function sets the locale of your application / main thread to the language of your choice and causes MFC to use the corresponding resource block.

    For example you can have a command line parameter to specify the language, parse the parameter in InitInstance and call SetThreadLocale with the corresponding LCID.

  4. #4
    Join Date
    May 2002
    Location
    Germany
    Posts
    487
    Thanks!
    I tried alpha137's way and made a working test-program under win2k. I took this way because it seems to be the easiest way for my in the moment: I do not need to create a DLL.
    Currently I'm trying to implement this into my major projecton my win98-pc, but I think I'll need some more time.

    Thanks to both of you!


    Marc

  5. #5
    Join Date
    May 2002
    Location
    Germany
    Posts
    487

    Too early

    Hi together!

    The SetThreadLocale() works - as Microsft says in MSDN- only on win 2000´and XP. It works at least not under win98.

    Do you have another idea?

    thanks!
    Marc

  6. #6
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    You could try to change the default System Locale on Win98, but I'm not sure how to do that... :/

    The better way is really to have resource-only DLL's for the different languages like IndikaNiva suggested.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured