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. How to change the scan code while posting WM_KEYDOWN and WM_KEYUP messages?

How to change the scan code while posting WM_KEYDOWN and WM_KEYUP messages?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comhardwarehelp
3 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.
  • L Offline
    L Offline
    ledallam
    wrote on last edited by
    #1

    Hello, I am working with win32 serial communication in VC++. My application communicates with a Control Panel hardware device which is similar to a Keyboard. It has various keys/buttons (”0-9 digit keys, A-Y alphabet keys and F1,F2,F3 keys”) on it , and is connected through the serial port of the PC. My application has to capture which key/button is pressed and released on the Control Panel board. When a key/button is pressed or released on the Control Panel board, my application should post the appropriate message to the main handling application which is responsible for processing the Key Down and Key Up messages received from Control Panel board. My application can find out the keys pressed or released on the Control Panel board. Now I need to post WM_KEYDOWN and WM_KEYUP messages when keys are pressed or released to the handling main application. But I should find a way to tell the handling main application, that the posted WM_KEYUP or WM_KEYDOWN message is from the Control Panel board and not from the Key board. The handling main application should be able to distinguish between the WM_KEYDOWN and WM_KEYUP messages from the Keyboard and the Control Panel board. When I went through the MSDN, http://msdn.microsoft.com/library/d.../wm\_keydown.asp I found that there is a field “Scan Code” in the lParam which is of use. I want to use this field to differentiate between messages of control panel buttons and keyboard keys. But I need some more information on this: 1. Are scan codes for keyboards standardized? 2. If scan codes are standardized, where can I get a list of the unused scan code range so that I may use them for the control panel? 3. How can I set these scan codes while posting the messages trough code? I am trying to search on google.com site for this information, but couldn’t get any useful link. I have never worked with this type of application and hence am unable to proceed further. Can anyone please help me in this? It would be of great help to me if you can give me some links or information on this area? Thanks in anticipation of information. Madhavi. Madhavi

    C 1 Reply Last reply
    0
    • L ledallam

      Hello, I am working with win32 serial communication in VC++. My application communicates with a Control Panel hardware device which is similar to a Keyboard. It has various keys/buttons (”0-9 digit keys, A-Y alphabet keys and F1,F2,F3 keys”) on it , and is connected through the serial port of the PC. My application has to capture which key/button is pressed and released on the Control Panel board. When a key/button is pressed or released on the Control Panel board, my application should post the appropriate message to the main handling application which is responsible for processing the Key Down and Key Up messages received from Control Panel board. My application can find out the keys pressed or released on the Control Panel board. Now I need to post WM_KEYDOWN and WM_KEYUP messages when keys are pressed or released to the handling main application. But I should find a way to tell the handling main application, that the posted WM_KEYUP or WM_KEYDOWN message is from the Control Panel board and not from the Key board. The handling main application should be able to distinguish between the WM_KEYDOWN and WM_KEYUP messages from the Keyboard and the Control Panel board. When I went through the MSDN, http://msdn.microsoft.com/library/d.../wm\_keydown.asp I found that there is a field “Scan Code” in the lParam which is of use. I want to use this field to differentiate between messages of control panel buttons and keyboard keys. But I need some more information on this: 1. Are scan codes for keyboards standardized? 2. If scan codes are standardized, where can I get a list of the unused scan code range so that I may use them for the control panel? 3. How can I set these scan codes while posting the messages trough code? I am trying to search on google.com site for this information, but couldn’t get any useful link. I have never worked with this type of application and hence am unable to proceed further. Can anyone please help me in this? It would be of great help to me if you can give me some links or information on this area? Thanks in anticipation of information. Madhavi. Madhavi

      C Offline
      C Offline
      Christopher Lloyd
      wrote on last edited by
      #2

      Why are you using WM_KEYUP and WM_KEYDOWN? If you want to distinguish your keys from those from the system why not just use messages such as: #define WM_CONTROLPANEL_KEYUP WM_APP+0 #define WM_CONTROLPANEL_KEYDOWN WM_APP+1

      B 1 Reply Last reply
      0
      • C Christopher Lloyd

        Why are you using WM_KEYUP and WM_KEYDOWN? If you want to distinguish your keys from those from the system why not just use messages such as: #define WM_CONTROLPANEL_KEYUP WM_APP+0 #define WM_CONTROLPANEL_KEYDOWN WM_APP+1

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        I would tend to agree. This statement The handling main application should be able to distinguish between the WM_KEYDOWN and WM_KEYUP messages from the Keyboard and the Control Panel board. already seems to imply that the application MUST see something different than regular 'keystrokes' from the panel. If the applciation is not going to process event fromt he control panel as regular keystrokes, then the application must be written to be specifically aware of the control panel events, as a result, you are free to define whatever interface you desire between your application and the control panel. It might make sens to follow something similar to the WM_KEY??? interfaces, so as to make your interface familiar to other developers. If you want your interface to be useful to other programmers, I would not use the WM_APP+??? messages in this case, since they already might be in use. You could use registered Widnow Messages if your system is in a DLL or static link library and communicates by sending window messages.

        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