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. Extracting lparam from WM_KEYDOWN MSG

Extracting lparam from WM_KEYDOWN MSG

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 0 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.
  • A Offline
    A Offline
    aquawicket
    wrote on last edited by
    #1

    I have PretranslateMessage() that checks for WM_KEYDOWN message to capture keystrokes. Then I do my processing from the code it gives me.. int key = (151 + HIWORD (pMsg->lParam) & 0x00ff); All works great, but I want to be able to test it to see if it's a repeat key before processing. That is, if the key is held down, I don't want the repeats to get through. How can I extract lparam bits into a var to see if the message is a repeat key? I beleive 0-15 in lparam tell repeat status. Sorry, I get kinda stumped when I get into working with data on bit and byte level. Thanks...

    M 1 Reply Last reply
    0
    • A aquawicket

      I have PretranslateMessage() that checks for WM_KEYDOWN message to capture keystrokes. Then I do my processing from the code it gives me.. int key = (151 + HIWORD (pMsg->lParam) & 0x00ff); All works great, but I want to be able to test it to see if it's a repeat key before processing. That is, if the key is held down, I don't want the repeats to get through. How can I extract lparam bits into a var to see if the message is a repeat key? I beleive 0-15 in lparam tell repeat status. Sorry, I get kinda stumped when I get into working with data on bit and byte level. Thanks...

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Something like this...

      WORD wRepeatCount = (WORD)(lParam & 0x0000FFFF);

      bool fPreviousKeyStateDown;
      if (lParam & 0x40000000)
      fPreviousKeyStateDown = true;
      else
      fPreviousKeyStateDown = false;

      Mark

      "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

      A M 2 Replies Last reply
      0
      • M Mark Salsbery

        Something like this...

        WORD wRepeatCount = (WORD)(lParam & 0x0000FFFF);

        bool fPreviousKeyStateDown;
        if (lParam & 0x40000000)
        fPreviousKeyStateDown = true;
        else
        fPreviousKeyStateDown = false;

        Mark

        "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

        A Offline
        A Offline
        aquawicket
        wrote on last edited by
        #3

        Thanks Mark.. your the man. :)

        1 Reply Last reply
        0
        • M Mark Salsbery

          Something like this...

          WORD wRepeatCount = (WORD)(lParam & 0x0000FFFF);

          bool fPreviousKeyStateDown;
          if (lParam & 0x40000000)
          fPreviousKeyStateDown = true;
          else
          fPreviousKeyStateDown = false;

          Mark

          "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

          M Offline
          M Offline
          Mizan Rahman
          wrote on last edited by
          #4

          Great, but how can I get the extended key info (i.e., ALT or CTRL keys) ? Thanks in advance. Mizan

          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