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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to set only integer value property for an edit control

How to set only integer value property for an edit control

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
8 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.
  • B Offline
    B Offline
    BiswaR
    wrote on last edited by
    #1

    Hi Guys, I have added one edit control to a dialog and attached a string variable to that. But i want only integers can be entered to the edit control and not characters.(N.B. I have attached a string variable to that edit control because i want that value to be received as string. Please help.

    N N T 4 Replies Last reply
    0
    • B BiswaR

      Hi Guys, I have added one edit control to a dialog and attached a string variable to that. But i want only integers can be entered to the edit control and not characters.(N.B. I have attached a string variable to that edit control because i want that value to be received as string. Please help.

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      Subclass CEdit and handle WM_CHAR message. If the char entered is a valid number then call base class implementation else you can ignore the char.


      Nibu thomas Software Developer

      1 Reply Last reply
      0
      • B BiswaR

        Hi Guys, I have added one edit control to a dialog and attached a string variable to that. But i want only integers can be entered to the edit control and not characters.(N.B. I have attached a string variable to that edit control because i want that value to be received as string. Please help.

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        Instead of creating the control variable of edit box as string, use integer type. if u wan to get the number as string just use the "Format" function of the CString. Then set Number (ES_NUMBER) style of the edit box, which only allows interger to enter. nave

        1 Reply Last reply
        0
        • B BiswaR

          Hi Guys, I have added one edit control to a dialog and attached a string variable to that. But i want only integers can be entered to the edit control and not characters.(N.B. I have attached a string variable to that edit control because i want that value to be received as string. Please help.

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          There is another way toooooooo Add the Number style to Edit. Whenever you want text in the edit box, Just call GetWindowText() :) nave

          B 1 Reply Last reply
          0
          • B BiswaR

            Hi Guys, I have added one edit control to a dialog and attached a string variable to that. But i want only integers can be entered to the edit control and not characters.(N.B. I have attached a string variable to that edit control because i want that value to be received as string. Please help.

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            on the resource editor, there is a "decimal" property which make the editBox accept only the 10 decimal digits... if you'd like to allow the . character, or a sign character like **+** or **-**, you'll have to overload the WM_CHAR event...


            TOXCCT >>> GEII power
            [toxcct][VisualCalc 2.24][3.0 soon...]

            1 Reply Last reply
            0
            • N Naveen

              There is another way toooooooo Add the Number style to Edit. Whenever you want text in the edit box, Just call GetWindowText() :) nave

              B Offline
              B Offline
              BiswaR
              wrote on last edited by
              #6

              Thanks a lot to all of you as all are good suggestions. But as per my requrement i feel "Add the Number style to Edit" will be the best solution. But i do not know exactly how to set it and also i am not able find the same. Nave, Can you please tell me how to set this style.

              T N 2 Replies Last reply
              0
              • B BiswaR

                Thanks a lot to all of you as all are good suggestions. But as per my requrement i feel "Add the Number style to Edit" will be the best solution. But i do not know exactly how to set it and also i am not able find the same. Nave, Can you please tell me how to set this style.

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                look in the properties of your editBox in the resource editor !!!


                TOXCCT >>> GEII power
                [toxcct][VisualCalc 2.24][3.0 soon...]

                1 Reply Last reply
                0
                • B BiswaR

                  Thanks a lot to all of you as all are good suggestions. But as per my requrement i feel "Add the Number style to Edit" will be the best solution. But i do not know exactly how to set it and also i am not able find the same. Nave, Can you please tell me how to set this style.

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #8

                  right click on the edit box -> take style tab There u can find the a check box named Number nave

                  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