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. Subclassing CEdit, OnChar

Subclassing CEdit, OnChar

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

    I'm doing some subclassing to allow only digits and one only of three allowable alpha characters at the end of the edit string. I'm overriding OnChar and find a need to modify the existing string before passing the allowable characters on. However, when I pass any character other than the character trapped by MyCEdit::OnChar to CEdit::OnChar it still results in passing the trapped character. I assume this is the way the system behaves but I don't understand why. Could someone enlighten me? The way I'm getting the job accomplished feels rather kudgy to me and I'd rather avoid it if I can. Thanks, Lilith

    I 1 Reply Last reply
    0
    • L Lilith C

      I'm doing some subclassing to allow only digits and one only of three allowable alpha characters at the end of the edit string. I'm overriding OnChar and find a need to modify the existing string before passing the allowable characters on. However, when I pass any character other than the character trapped by MyCEdit::OnChar to CEdit::OnChar it still results in passing the trapped character. I assume this is the way the system behaves but I don't understand why. Could someone enlighten me? The way I'm getting the job accomplished feels rather kudgy to me and I'd rather avoid it if I can. Thanks, Lilith

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      try to override WM_KEYDOWN (OnKeyDown?) also. if you control both OnChar and OnKeyDown, it should work.


      A nice tool for optimizing your Microsoft html-help contents. Includeh10

      F 1 Reply Last reply
      0
      • I includeh10

        try to override WM_KEYDOWN (OnKeyDown?) also. if you control both OnChar and OnKeyDown, it should work.


        A nice tool for optimizing your Microsoft html-help contents. Includeh10

        F Offline
        F Offline
        FarPointer
        wrote on last edited by
        #3

        if you control both OnChar and onkeydown, it should work. This is the note given in MSDN explaining the correct scenario explaning that you cant fool the system . Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function. in your case map the EN_UPDATE ,check wether the characters are integers and if the count goes above 10 , you do the required . Regards FarPointer.

        L 1 Reply Last reply
        0
        • F FarPointer

          if you control both OnChar and onkeydown, it should work. This is the note given in MSDN explaining the correct scenario explaning that you cant fool the system . Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function. in your case map the EN_UPDATE ,check wether the characters are integers and if the count goes above 10 , you do the required . Regards FarPointer.

          L Offline
          L Offline
          Lilith C
          wrote on last edited by
          #4

          Actually that's what I originally did except that I used EN_CHANGE, which may have been a mistake. Although a similar approach had worked before, this time I somehow got an odd character at the beginning of the string when I re-read it from the edit control. Using a combination of OnChar to filter the input and EN_CHANGE to process the string at least would have the benefit of reducing my logic's complexity. Lilith

          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