MAKELANGID

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Howard Kaikow

    MAKELANGID

    In C++, one can use the MAKELANGID macro from Winnt.h.

    Can that be used in C#?

    --
    http://www.standards.com/; See Howard Kaikow's web site.


  • Eyal Safran

    #2
    Re: MAKELANGID

    Since there are no macros in C#, and since you can view the winnt.h
    file...
    why didn't you create methods like this:

    /*
    A language ID is a 16 bit value which is the combination of a
    primary language ID and a secondary language ID. The bits are
    allocated as follows:

    +-----------------------+-------------------------+
    | Sublanguage ID | Primary Language ID |
    +-----------------------+-------------------------+
    15 10 9 0 bit


    Language ID creation/extraction macros:

    MAKELANGID - construct language id from a primary language id
    and
    a sublanguage id.
    PRIMARYLANGID - extract primary language id from a language id.
    SUBLANGID - extract sublanguage id from a language id.


    #define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
    #define PRIMARYLANGID(l gid) ((WORD )(lgid) & 0x3ff)
    #define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
    */

    public ushort MAKELANGID(byte primaryLanguage , byte subLanguage)
    {
    return (ushort)((((ush ort)subLanguage ) << 10) |
    (ushort)primary Language);
    }

    public byte PRIMARYLANGID(u short languageId)
    {
    return (byte)(language Id & 0x3ff);
    }

    public byte SUBLANGID(ushor t languageId)
    {
    return (byte)(language Id >> 10);
    }

    Eyal.

    Comment

    • Joerg Jooss

      #3
      Re: MAKELANGID

      Howard Kaikow wrote:
      [color=blue]
      > In C++, one can use the MAKELANGID macro from Winnt.h.
      >
      > Can that be used in C#?[/color]

      You cannot use the macro per se, but you easily reuse the macro's C++
      expression in C#.

      Cheers,
      --

      mailto:news-reply@joergjoos s.de

      Comment

      • Eyal Safran

        #4
        Re: MAKELANGID

        How do you reuse C++ macros in C#?

        Eyal.

        Comment

        • Joerg Jooss

          #5
          Re: MAKELANGID

          Eyal Safran wrote:
          [color=blue]
          > How do you reuse C++ macros in C#?
          >
          > Eyal.[/color]

          Eyal,

          quoting helps keeping a post in context. Also, read what I actually
          wrote:

          "[...] you easily reuse the macro's C++ *expression* in C#."

          Which is exactly what you did in your reply.

          Cheers,
          --

          mailto:news-reply@joergjoos s.de

          Comment

          • Jon Skeet [C# MVP]

            #6
            Re: MAKELANGID

            Eyal Safran <eyal@mokedor.c om> wrote:[color=blue]
            > How do you reuse C++ macros in C#?[/color]

            Not the macro - the macro *expression*. Basically translating it into
            C#, as you did in your other post on this thread.

            --
            Jon Skeet - <skeet@pobox.co m>
            Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

            If replying to the group, please do not mail me too

            Comment

            • Howard Kaikow

              #7
              Re: MAKELANGID

              "Eyal Safran" <eyal@mokedor.c om> wrote in message
              news:1117875929 .918167.268240@ o13g2000cwo.goo glegroups.com.. .[color=blue]
              > Since there are no macros in C#, and since you can view the winnt.h
              > file...
              > why didn't you create methods like this:[/color]

              Thanx.


              Comment

              Working...