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. Entering Negative values in MSVS 6.0 Edit dialogs.

Entering Negative values in MSVS 6.0 Edit dialogs.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
9 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.
  • R Offline
    R Offline
    Ralph_L
    wrote on last edited by
    #1

    Re: Entering Negative values in MSVS 6.0 Edit dialogs. Has anyone found a solution or work around for the problem with entering a “negative” value in an Edit-Control Dialog box? When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key! :| I am aware of one work around first enter the number, then use HOME key, and then enter the – key, but this is very clumsy and many users would not know to use this.

    Ralph_L

    L D P 3 Replies Last reply
    0
    • R Ralph_L

      Re: Entering Negative values in MSVS 6.0 Edit dialogs. Has anyone found a solution or work around for the problem with entering a “negative” value in an Edit-Control Dialog box? When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key! :| I am aware of one work around first enter the number, then use HOME key, and then enter the – key, but this is very clumsy and many users would not know to use this.

      Ralph_L

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Ralph_L wrote:

      in MSVS 6.0 Edit dialogs.

      What is an "MSVS 6.0 Edit dialog"? You mean like where you enter the number of spaces to use for a Tab? Why would you put a negative number in there?

      R 1 Reply Last reply
      0
      • L led mike

        Ralph_L wrote:

        in MSVS 6.0 Edit dialogs.

        What is an "MSVS 6.0 Edit dialog"? You mean like where you enter the number of spaces to use for a Tab? Why would you put a negative number in there?

        R Offline
        R Offline
        Ralph_L
        wrote on last edited by
        #3

        MSVS 6.0 is Microsoft Visual Studio ver 6.0 for C++/MFC. The Edit box is a Dialog Edit box where one can enter value into.

        Ralph_L

        1 Reply Last reply
        0
        • R Ralph_L

          Re: Entering Negative values in MSVS 6.0 Edit dialogs. Has anyone found a solution or work around for the problem with entering a “negative” value in an Edit-Control Dialog box? When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key! :| I am aware of one work around first enter the number, then use HOME key, and then enter the – key, but this is very clumsy and many users would not know to use this.

          Ralph_L

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

          Ralph_L wrote:

          When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key!

          Because "-" is not a numeric character. Use a masked edit control.


          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          L R 2 Replies Last reply
          0
          • D David Crow

            Ralph_L wrote:

            When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key!

            Because "-" is not a numeric character. Use a masked edit control.


            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            Hey! I was fishing in here and had not bagged my limit .... yet! ;P

            1 Reply Last reply
            0
            • D David Crow

              Ralph_L wrote:

              When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key!

              Because "-" is not a numeric character. Use a masked edit control.


              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              R Offline
              R Offline
              Ralph_L
              wrote on last edited by
              #6

              Thank for the reply David, Would you please explain 'masked edit control' and provide sample perhaps? :~ This is an Edit box in a Dialog base application, and made via the Resource Editor.

              Ralph_L

              D 1 Reply Last reply
              0
              • R Ralph_L

                Re: Entering Negative values in MSVS 6.0 Edit dialogs. Has anyone found a solution or work around for the problem with entering a “negative” value in an Edit-Control Dialog box? When a ‘int type’ is specified and validation is used or not, the same “Enter a Number Error” dialog is displayed when the first entry is the “ - “ key! :| I am aware of one work around first enter the number, then use HOME key, and then enter the – key, but this is very clumsy and many users would not know to use this.

                Ralph_L

                P Offline
                P Offline
                pierre_ribery
                wrote on last edited by
                #7

                Create a class derived from CEdit, let us call it CIntEdit, and handle WM_CHAR message: void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //Allowed characters CString numeric = "-0123456789."; if (numeric.Find(nChar) != -1) CEdit::OnChar(nChar, nRepCnt, nFlags); } This will only accept integer values. Pierre.

                R 1 Reply Last reply
                0
                • P pierre_ribery

                  Create a class derived from CEdit, let us call it CIntEdit, and handle WM_CHAR message: void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //Allowed characters CString numeric = "-0123456789."; if (numeric.Find(nChar) != -1) CEdit::OnChar(nChar, nRepCnt, nFlags); } This will only accept integer values. Pierre.

                  R Offline
                  R Offline
                  Ralph_L
                  wrote on last edited by
                  #8

                  Thanks Pierre, I will give this a try.

                  Ralph_L

                  1 Reply Last reply
                  0
                  • R Ralph_L

                    Thank for the reply David, Would you please explain 'masked edit control' and provide sample perhaps? :~ This is an Edit box in a Dialog base application, and made via the Resource Editor.

                    Ralph_L

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

                    Ralph_L wrote:

                    Would you please explain 'masked edit control' and provide sample perhaps?

                    See here.


                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    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