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 replace default keys behaivour in Edit control

How to replace default keys behaivour in Edit control

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorial
4 Posts 2 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.
  • S Offline
    S Offline
    Saqib Razzaq
    wrote on last edited by
    #1

    I've a CEdit class. When you press 'a' from the keyboard, it writes 'a' in the control which is obvious. The problem is that I want to change this behaviour. when I press 'a' from the keyboard, some other character e.g. 'b' should be written. I have a 2D array that has mappings of all the keyboard keys. Actually I am dealing with Unicode (a multilingual application). Suppose I want to replace 'a' character with unicode 23456, which message should I handle. I have tried WM_KEYDOWN and WM_CHAR and changed the virtual key code. but it did not worked. In short, please tell me any way in which I can display 'b' in the edit control when 'a' is pressed. Saqib.

    L 1 Reply Last reply
    0
    • S Saqib Razzaq

      I've a CEdit class. When you press 'a' from the keyboard, it writes 'a' in the control which is obvious. The problem is that I want to change this behaviour. when I press 'a' from the keyboard, some other character e.g. 'b' should be written. I have a 2D array that has mappings of all the keyboard keys. Actually I am dealing with Unicode (a multilingual application). Suppose I want to replace 'a' character with unicode 23456, which message should I handle. I have tried WM_KEYDOWN and WM_CHAR and changed the virtual key code. but it did not worked. In short, please tell me any way in which I can display 'b' in the edit control when 'a' is pressed. Saqib.

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

      Try to override PreTranslateMessage regards

      S 1 Reply Last reply
      0
      • L Lost User

        Try to override PreTranslateMessage regards

        S Offline
        S Offline
        Saqib Razzaq
        wrote on last edited by
        #3

        Thanks alot for your help Greg. I got my problem solved. PreTranslateMessage function handed the whole MSG structure to me. I traped the WM_CHAR message and changed the wParam to 'b' when it was actually 'a'. if (pMsg->wParam == 'a') pMsg->wParam = 'b'; Codeproject is really amazing site. Thankyou once again. Saqib.

        L 1 Reply Last reply
        0
        • S Saqib Razzaq

          Thanks alot for your help Greg. I got my problem solved. PreTranslateMessage function handed the whole MSG structure to me. I traped the WM_CHAR message and changed the wParam to 'b' when it was actually 'a'. if (pMsg->wParam == 'a') pMsg->wParam = 'b'; Codeproject is really amazing site. Thankyou once again. Saqib.

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

          You're welcome! :) regards

          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