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 deny zero on CEdit

How to deny zero on CEdit

Scheduled Pinned Locked Moved C / C++ / MFC
tutoriallearning
9 Posts 5 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.
  • V Offline
    V Offline
    virtualsamurai
    wrote on last edited by
    #1

    I'm just a beginner. I can set the range of SpinButtn but don't know how to deny values outside Min and Max thru keyboard input w/o using messsage box

    H D M 3 Replies Last reply
    0
    • V virtualsamurai

      I'm just a beginner. I can set the range of SpinButtn but don't know how to deny values outside Min and Max thru keyboard input w/o using messsage box

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Did you use CSpinButtonCtrl::SetRange

      _**


      **_

      WhiteSky


      V 1 Reply Last reply
      0
      • H Hamid Taebi

        Did you use CSpinButtonCtrl::SetRange

        _**


        **_

        WhiteSky


        V Offline
        V Offline
        virtualsamurai
        wrote on last edited by
        #3

        For the SpinButton yes it's working, problem is It allows values outside the range thru keyboard input thanks

        Z 1 Reply Last reply
        0
        • V virtualsamurai

          For the SpinButton yes it's working, problem is It allows values outside the range thru keyboard input thanks

          Z Offline
          Z Offline
          Zac Howland
          wrote on last edited by
          #4

          Using the ClassView, add an integer variable that is attached to the edit control. This will add a DDX_ function call in your DoDataExchange method. You will also note that there is a min and max range you can set for the variable that will add a DDV_ call in DoDataExchange.

          If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

          V 2 Replies Last reply
          0
          • V virtualsamurai

            I'm just a beginner. I can set the range of SpinButtn but don't know how to deny values outside Min and Max thru keyboard input w/o using messsage box

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            If the maximum value for the edit control is 999, for example, use SetLimitText(3). If the maximum value is something else like 756, you can't keep 757 from being pasted or typed into the control, but you can disable the OK button. There are other possible solutions, but without more knowledge of the problem, those would be guesses at best.


            "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

            "Judge not by the eye but by the heart." - Native American Proverb

            1 Reply Last reply
            0
            • Z Zac Howland

              Using the ClassView, add an integer variable that is attached to the edit control. This will add a DDX_ function call in your DoDataExchange method. You will also note that there is a min and max range you can set for the variable that will add a DDV_ call in DoDataExchange.

              If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

              V Offline
              V Offline
              virtualsamurai
              wrote on last edited by
              #6

              thanks Zac I'll try that.

              1 Reply Last reply
              0
              • V virtualsamurai

                I'm just a beginner. I can set the range of SpinButtn but don't know how to deny values outside Min and Max thru keyboard input w/o using messsage box

                M Offline
                M Offline
                Manfred Staiger
                wrote on last edited by
                #7

                By means of "subclassing" the CEdit you can overwrite it's message handlers. This way you can sort out the characters you want to block. Search for "Subclassing" or "SubclassDlgItem" here in the forum. There are good articles about the subject.

                MS

                1 Reply Last reply
                0
                • Z Zac Howland

                  Using the ClassView, add an integer variable that is attached to the edit control. This will add a DDX_ function call in your DoDataExchange method. You will also note that there is a min and max range you can set for the variable that will add a DDV_ call in DoDataExchange.

                  If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

                  V Offline
                  V Offline
                  virtualsamurai
                  wrote on last edited by
                  #8

                  By the way I messed up my project by adding and deleting a dialog and rename the new with the old one. can't open class wizard and keeps on prompting to locate the source even though I set selected it already

                  Z 1 Reply Last reply
                  0
                  • V virtualsamurai

                    By the way I messed up my project by adding and deleting a dialog and rename the new with the old one. can't open class wizard and keeps on prompting to locate the source even though I set selected it already

                    Z Offline
                    Z Offline
                    Zac Howland
                    wrote on last edited by
                    #9

                    If need be, you can add the code by hand. All it requires is declaring an integer variable in your dialog class, and adding the DDX and DDV calls in DoDataExchange. If you create another dialog app to test it with, you can see the format for those function calls.

                    If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

                    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