Announcement

Collapse
No announcement yet.

How to use MAKELANGID in PBDLL60?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use MAKELANGID in PBDLL60?

    Guys,

    In my "WIN32.HLP" I found this stuff, referred to as a macro:
    Code:
    WORD MAKELANGID(
    
        USHORT usPrimaryLanguage,	// primary language identifier
        USHORT usSubLanguage	// sublanguage identifier
       );
    Obviously it is creating a WORD INTEGER (should be LONG in PB, I think?) as a language identifier. Does someone know how to use this in PB?

    Thanks

    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Wrong idea

    [This message has been edited by Semen Matusovski (edited March 14, 2001).]

    Comment


    • #3
      Actually...
      Code:
      #define MAKELANGID(p, s) ((((WORD)(s)) << 10) | (WORD)(p))
      This translates to something like:
      Code:
      FUNCTION MAKELANGID (BYVAL p AS WORD, BYVAL s AS WORD) AS WORD
          SHIFT LEFT s, 10
          FUNCTION = s OR p
      END FUNCTION

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Agree. usPrimaryLanguage + &H400 * usSubLanguage (English USA - &H409, Russian - &H419)



        ------------------
        E-MAIL: [email protected]

        Comment


        • #5
          Tom,
          Obviously this makes sense. The function returns the same value that's returned by
          the GetLocaleInfo API (see code). One additional question: in your sample code the
          FUNCTION is defined AS WORD, but in WIN32API.INC several FUNCTIONs do refer to the
          language-ID param AS LONG. Maybe the FUNCTION should return a long integer in order
          to avoid "parameter mismatch" errors?

          Thanks for solving my problem. You did'nt take away my disappointment, though. I intended
          to use the function to create international message boxes, using:
          Code:
          dummy& = MessageBoxEx(0, szMessage, szCaption, %MB_YESNO, _
                                              MAKELANGID(%LANG_DUTCH, %SUBLANG_DUTCH))
          but MSDN reports that it does not work. See: http://support.microsoft.com/support.../Q152/6/70.asp
          However, Microsoft says it should work under Windows 2000, which I don't have, unf.
          Code:
          #COMPILE EXE
          #INCLUDE "WIN32API.INC"
           
          FUNCTION MAKELANGID(BYVAL LangID AS WORD, BYVAL SubLangID AS WORD) AS WORD
            SHIFT LEFT SubLangID, 10
            FUNCTION = LangID OR SubLangID
          END FUNCTION
           
          FUNCTION PBMain() AS LONG
            LOCAL szLangID AS ASCIIZ * 5, LangId AS LONG
            GetLocaleInfo %LOCALE_USER_DEFAULT, %LOCALE_ILANGUAGE, szLangID, SIZEOF(szLangID)
            LangId = VAL("&H" + szLangID)
            MSGBOX "Both FUNCTIONs should return 1043 for Dutch" + REPEAT$(2, $CRLF) + _
                   "GetLocaleInfo (HEX " + szLangId + "): " + FORMAT$(LangID) + $CRLF + _
                   "MAKELANGID: " + FORMAT$(MAKELANGID(%LANG_DUTCH, %SUBLANG_DUTCH)), _
                   64, "Language identifier"
          END FUNCTION
          ------------------
          mailto:[email protected][email protected]</A>
          www.basicguru.com/zijlema/

          [This message has been edited by Egbert Zijlema (edited March 15, 2001).]

          Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
          http://zijlema.basicguru.eu
          *** Opinions expressed here are not necessarily untrue ***

          Comment


          • #6
            FWIW...

            I get 1033 and 1043 respectively. I'm set for NZ locale, and I don't have Dutch language support in my Win2K machine.

            When I try your MessageBoxEx() call, it displays in English (as would probably be expected since I'd probably need to install Dutch to test the theory!)

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Thanks Lance,

              Stupid me!!!
              The GetLocaleInfo API of course always returns the locale language identifier. So, my code is not fit for an appropriate test.
              By the way: the value you get, 1033, stands for English_US, not for New Zealand. Check and modify your regional settings to correct this 'wrong' setting.

              As far as the MessageBoxEx function is involved: according to MSDN it should create MsgBox controls in the language specified by MAKELANGID. Anyhow under Windows 2000, 'they' say.

              I think, using MAKELANGID is not such a good idea, after all, because as a programmer you never know in which country your applications will be used.
              If the FUNCTION did work, I'd do it as follows:
              1. get the local language identifier using GetLocaleInfo
              2. translate the returned ASCIIZ to a long integer and pass this value thru MessagBoxEx
              Message Box controls should appear in the language of the country where the program is used then (note: this is only functional in a Windows version not supporting the local language. For instance, when I use a Dutch edition of Windows, my message box controls appear in Dutch by default).

              ----------------
              mailto:[email protected][email protected]</A>
              www.basicguru.com/zijlema/



              [This message has been edited by Egbert Zijlema (edited March 15, 2001).]

              Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
              http://zijlema.basicguru.eu
              *** Opinions expressed here are not necessarily untrue ***

              Comment


              • #8
                Duh! Yes I should have rechecked my settings... I had forgotten that I had changed my Win2K Locale to US-English a few months ago... Thanks for the wakeup call!

                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment


                • #9
                  One additional question: in your sample code the
                  FUNCTION is defined AS WORD, but in WIN32API.INC several FUNCTIONs do refer to the
                  language-ID param AS LONG. Maybe the FUNCTION should return a long integer in order
                  to avoid "parameter mismatch" errors?
                  MAKELANGID is defined as returning a WORD value. However, any WORD value will fit
                  in a LONG with room to spare, so there is no real conflict involved. If you aim to
                  pass the function result directly to a function that takes a LONG, consider the
                  BYCOPY keyword.


                  ------------------
                  Tom Hanlin
                  PowerBASIC Staff

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎