CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2005
    Posts
    11

    GetLocaleInfo and Non-english Windowsversions

    Hi folks,
    I've got a really weird problem. From a C++Application I have to export data to excel using OLE (don't ask why, just take it as it is ;-)). I have to tell excel the format settings for each cell (using the numberformat-property). If a value is a date, things really start being strange. On a german windows with a german excel numberformat must be filled with "TT.MM.JJJJ" instead of "DD.MM.YYYY".

    In the control-panel these placeholders are also localized. But if I call GetLocaleInfo() with the appropriate parameters, I always get format string with the english placeholders ("d", "m" and "y"). And as the software runs in a lot of countries I have quiet a problem with that behaviour ;-) What I want to know: Is there any chance to retrieve that localized date-format string of the control panel's country settings?
    Any help is welcome...

    Chabba

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: GetLocaleInfo and Non-english Windowsversions

    take a look at ::GetDateFormat(...)

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Sep 2005
    Posts
    11

    Re: GetLocaleInfo and Non-english Windowsversions

    Hi golanshahar,
    thanks for your reply, but I don't want to format a date but get the localized format string as shown in the control panel's country settings.
    In an english windows version you will see there "YYYY/DD/MM" or something else. In a german windows version you'll find "JJJJ.TT.MM". And in another windows version something else. What I need at least are the abbreviation letters "YMD" or "JMT" or whatever....
    Greez, chabba

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: GetLocaleInfo and Non-english Windowsversions

    oh sorry sorry now i got your question

    tell me if you pass to ::GetLocaleInfo(..) as first parameter
    Code:
      LCID lcid; 
      lcid = MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN),SORT_DEFAULT);
    is still returning result in english?

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  5. #5
    Join Date
    Sep 2005
    Posts
    11

    Re: GetLocaleInfo and Non-english Windowsversions

    Hi golanshahar,
    no need to be sorry :-) Most of the people I talked to didn't get it on the 1st try ;-) And after having done some "googleing" I now know, that this is a very uncommon problem. What really is astonishing with it, is that Excel has something like a "localized OLE-Interface". Never seen a localized API before...

    Ok, now: Thanks for your idea. Tried it, but this also returned "dd.MM.yyyy".
    Parsing the registry, this is exactly the string under HKCU\ControlPanel\International.
    Seems to me as if this translation is done internally by the control panel.

    The other question I deal with is: Is Excel getting this string from somewhere
    within Windows and then expecting it via OLE or is it expecting it, because it is a german Excel? I really hope the 1st, because using a brazilian Excel on a french Windows is really not uncommon to our customers...

    Greez, chabba

  6. #6
    Join Date
    May 2005
    Posts
    4,954

    Re: GetLocaleInfo and Non-english Windowsversions

    so it didnt work? bummer.

    oh i have an idea for you. its not VERY GOOD but it might work.

    in the installed excel can see the localized string lets say in german? i mean manually? if so maybe you can use excel automation to bring that format out.

    another not very good idea is to keep a list for all the localized windows you are going to work with, you will use the ::GetLocaleInfo(..) to get the string in english and you will do the converions yourself based on the engilsh input.
    its not very good idea -it may be ok only if you going to deal will couple of localized system but if not then i wouldnt do it.

    if i will have another idea i will let you know...

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  7. #7
    Join Date
    Sep 2005
    Posts
    11

    Re: GetLocaleInfo and Non-english Windowsversions

    Well, I think it's best to have a list with these strings on my own with the option to let user edit it...
    At first I will do it that way (time is running low, you know ;-))
    Thank you so far...

    Keep on rockin'

    Chabba

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