Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. right or left control-key ???

right or left control-key ???

Scheduled Pinned Locked Moved C / C++ / MFC
questiongame-dev
6 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am about to write a dll that allows users to define keys (e. g. for a game), but I cannot distinguish between the right and left ctrl-key. In the second parameter the WM_KEYDOWN-Message gives me this information in a DWORD-value (LPARAM), but I am not able to decode the information. How can I get this done? Thank you.

    PJ ArendsP 1 Reply Last reply
    0
    • L Lost User

      I am about to write a dll that allows users to define keys (e. g. for a game), but I cannot distinguish between the right and left ctrl-key. In the second parameter the WM_KEYDOWN-Message gives me this information in a DWORD-value (LPARAM), but I am not able to decode the information. How can I get this done? Thank you.

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      the right key (extended key) is pressed if bit 24 of lParam is set. so use the bitwise AND operator (&) to check that bit.

      if (lParam & 0x01000000)
      {
      // An extended key
      }

      :)

      Within you lies the power for good; Use it!

      L 1 Reply Last reply
      0
      • PJ ArendsP PJ Arends

        the right key (extended key) is pressed if bit 24 of lParam is set. so use the bitwise AND operator (&) to check that bit.

        if (lParam & 0x01000000)
        {
        // An extended key
        }

        :)

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thank you. :-) Your tip works. But one question remains: When I read "bit 24 of lParam", how do I get the binary code like "01000000" ? :confused:

        PJ ArendsP 1 Reply Last reply
        0
        • L Lost User

          Thank you. :-) Your tip works. But one question remains: When I read "bit 24 of lParam", how do I get the binary code like "01000000" ? :confused:

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          0x01000000 is not a binary code, it is a hexadecimal number (note the '0x'). Each digit in a hexadecimal number represents four bits.

          Hexadecimal Digital Binary
          0 0 0000
          1 1 0001
          2 2 0010
          3 3 0011
          4 4 0100
          5 5 0101
          6 6 0110
          7 7 0111
          8 8 1000
          9 9 1001
          A 10 1010
          B 11 1011
          C 12 1100
          D 13 1101
          E 14 1110
          F 15 1111

          So when we say bit 24 is set we get this

          bit 33 2 2 1 1
          number 1098 7654 3210 9876 5432 1098 7654 3210
          | | | | | | |
          binary 0000 0001 0000 0000 0000 0000 0000 0000

          hex 0 1 0 0 0 0 0 0

          Also look up bitwise operators in MSDN

          Within you lies the power for good; Use it!

          R 1 Reply Last reply
          0
          • PJ ArendsP PJ Arends

            0x01000000 is not a binary code, it is a hexadecimal number (note the '0x'). Each digit in a hexadecimal number represents four bits.

            Hexadecimal Digital Binary
            0 0 0000
            1 1 0001
            2 2 0010
            3 3 0011
            4 4 0100
            5 5 0101
            6 6 0110
            7 7 0111
            8 8 1000
            9 9 1001
            A 10 1010
            B 11 1011
            C 12 1100
            D 13 1101
            E 14 1110
            F 15 1111

            So when we say bit 24 is set we get this

            bit 33 2 2 1 1
            number 1098 7654 3210 9876 5432 1098 7654 3210
            | | | | | | |
            binary 0000 0001 0000 0000 0000 0000 0000 0000

            hex 0 1 0 0 0 0 0 0

            Also look up bitwise operators in MSDN

            R Offline
            R Offline
            Ryan Park
            wrote on last edited by
            #5

            I don't have any concern on this stuff, but I want to say that you are very kind to do this! Honestly I didn't ever tried to explain in detail in helping others although I've got tons of information from others like you. Sincerely I honor your work. Regards, Ryan

            PJ ArendsP 1 Reply Last reply
            0
            • R Ryan Park

              I don't have any concern on this stuff, but I want to say that you are very kind to do this! Honestly I didn't ever tried to explain in detail in helping others although I've got tons of information from others like you. Sincerely I honor your work. Regards, Ryan

              PJ ArendsP Offline
              PJ ArendsP Offline
              PJ Arends
              wrote on last edited by
              #6

              :-O

              Within you lies the power for good; Use it!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups