CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2009
    Posts
    2

    Localization MessageBoxEx

    Hi there,

    i'm currently trying to localize an application but got problems when the application locale is different from the OS locale.

    I'm trying to display a message boxes with the buttons in localized language.

    To do so im using the MessageBoxEx function

    int MessageBoxEx(
    HWND hWnd,
    LPCTSTR lpText,
    LPCTSTR lpCaption,
    UINT uType,
    WORD wLanguageId
    );

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

    For testing i'm using a WindowsXP Pro SP3 machine with an english installation and the french MUI pack installed.
    Developing with visual studio 2008 SP1 and windowsSDK 7.0

    my function call is the following:

    MessageBoxEx(NULL,"mymessage","mytitle",MB_YESNO | MB_ICONWARNING, MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US))

    this works out great.
    when using english or french as OS language setting my message box shows in english language, complete with the "yes" and "no" buttons

    while this

    MessageBoxEx(NULL,"monmessage","montitle",MB_YESNO | MB_ICONWARNING, MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH))

    is a different story.
    when using french language as OS language it shows ok, with "oui" and "non" as button labels
    but when using the same executable and english as os language the button labels show as "yes" and "no".

    The problem is that im not able to change the language on an english OS language where on the french OS it just works fine.
    My application should be independent from the os locale an it should be configurable which language is used.

    i tried to google this and found a lot but couldn't find a definitive answer wheter its a problem on my side or it isn't possible to do what i want with MessageBoxEx and i must build my own solution.

    can someone please give me a definitive answer?

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Localization MessageBoxEx

    Where is the problem? If a user has selected English, in his settings, then it is ok to have "Yes" and "no" instead of "Oui" and "Non", isn't it?

    Quel est le problème ? Si un utilisateur choisit l'anglais dans sa configuration, il est normal qu'il ait "Yes" et "No" au lieu de "Oui" et "Non", ne croyez vous pas ?

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Localization MessageBoxEx

    Quote Originally Posted by olivthill2 View Post
    Where is the problem?
    The problem, IMHO, is in the fact that MessageBoxEx does not work as it described in MSDN (or, at least not as OP has expected it to work)
    Victor Nijegorodov

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Localization MessageBoxEx

    According to this, the language id is pretty much ignored: http://blogs.msdn.com/michkap/archiv...01/522164.aspx

    So you'll have to stop using MessageBox* if you want to localize just your application (ignoring OS settings).

    gg

  5. #5
    Join Date
    Nov 2009
    Posts
    2

    Re: Localization MessageBoxEx

    Quote Originally Posted by olivthill2 View Post
    Where is the problem? If a user has selected English, in his settings, then it is ok to have "Yes" and "no" instead of "Oui" and "Non", isn't it?
    The problem is that the application language setting can't be set to french when im using the english OS language.

    So i guess i won't be able to avoid creating a custom message box to show the language and i will do as suggested and replace all MessageBox* calls.

    thx

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Localization MessageBoxEx

    Yes, you can customize AfxMessageBox (or ::MessageBox) using CBT hook and change all messagebox button captions according to your needs.
    See:
    MessageBox with Custom Button Captions
    CBT Message Box
    Fancy Custom MessageBox
    Victor Nijegorodov

Tags for this Thread

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