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