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 can i disable pressing of special characters(@,#,$,%,^,&,*,~,!) on Editbox control?

How can i disable pressing of special characters(@,#,$,%,^,&,*,~,!) on Editbox control?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 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
    Le rner
    wrote on last edited by
    #1

    Hi all, Please anyone can tell me how can i stop enter special cahracters (@,#,$,%,^,&,*,~,!) in Editbox. Thanks in advance.

    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

    Y _ 2 Replies Last reply
    0
    • L Le rner

      Hi all, Please anyone can tell me how can i stop enter special cahracters (@,#,$,%,^,&,*,~,!) in Editbox. Thanks in advance.

      IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

      Y Offline
      Y Offline
      Yajnesh Narayan Behera
      wrote on last edited by
      #2

      You can perform it in three ways. One is override PreTranslateMessage. Another one is to subclass your Editbox. Also there is another one derive your custom editbox from CEditBox, on WM_CHAR message you can disbale special character.

      1 Reply Last reply
      0
      • L Le rner

        Hi all, Please anyone can tell me how can i stop enter special cahracters (@,#,$,%,^,&,*,~,!) in Editbox. Thanks in advance.

        IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        Subclass CEdit and override subclass OnPreTranslate(). you can also do it with the EN_CHANGE event in your dialog class but that would require some logic of storing the string, comparing it with the previous one, finding if the new character is the one which you DON'T want etc etc. Hope it helps.

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        L 1 Reply Last reply
        0
        • _ _AnsHUMAN_

          Subclass CEdit and override subclass OnPreTranslate(). you can also do it with the EN_CHANGE event in your dialog class but that would require some logic of storing the string, comparing it with the previous one, finding if the new character is the one which you DON'T want etc etc. Hope it helps.

          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          L Offline
          L Offline
          Le rner
          wrote on last edited by
          #4

          Can you show any example of this. Thanks.

          IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

          L 1 Reply Last reply
          0
          • L Le rner

            Can you show any example of this. Thanks.

            IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

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

            Hi, there is an excellent Codeproject article called CFilterEdit: Use Regular Expressions to filter your input by Ben Hanson. This can serve you well as a base clase for your problem. http://www.codeproject.com/KB/edit/FilterEdit.aspx[^] There are already some sample derived classes like * CCurrencyEdit * CDateTimeEdit * CFloatEdit * CIntEdit * CUIntEdit * CUIntRangeEdit * CSpin So long, Stefan

            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