|
how can i restrict user from pressing shift key in editbox ..
plz help me
|
|
|
|
|
Can you tell us why you want to block it?
|
|
|
|
|
i want to make user to only input numbers (1 to so on) but not spectial charters using shift like (%,#,@,!,^,&,*,()) etc
|
|
|
|
|
ani_ikram wrote: i want to make user to only input numbers
You can handle the WM_CHAR message of edit control and inside that, you can check, whether the character is number or not. If it is not number, just return from that function, with out calling the base class'( CEdit ) function.
|
|
|
|
|
can u plz send me code so that i can get idea
|
|
|
|
|
The below code will block the special charcters but permits alphabets and numbers
void EditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if( !isdigit(nChar) && !isalpha( nChar ))
{
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
|
|
|
|
|
void EditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if( !isdigit(nChar) && !isalpha( nChar )) { return; } CEdit::OnChar(nChar, nRepCnt, nFlags);}
i hv used this method but its also restricting to enter float value while i want to enable float numbers as well plz tell me how to do it
|
|
|
|
|
ani_ikram wrote: well plz tell me how to do it
Just modify the checking as follows
if( !isdigit(nChar) && !isalpha( nChar ) && nChar != _T('.'))
|
|
|
|
|
thanks alot nave u really solved my problem
|
|
|
|
|
You are welcome...
|
|
|
|
|
BTW, if you only wanted to have an edit control into which you can enter a float value, there are hundreds of article about that subject, you only have to search for it on codeproject. Here[^] is an example.
The problem with your approach is that it is not secure: nothing prevents the user to enter a dot several time. So, instead of reinventing the wheel and rewriting the validation code all over again(it's not that trivial because, you have also to take into account that the user might delete some characters, change the cursor location, ...) why don't you look for a control that does this already ?
|
|
|
|
|
If you do not want floating point numbers you can set the Numbers only property in resource editor.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
if you want to use only numbers than you can use number property of EditBox.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
if you want to block Special character than you can subclass your edit control and handle OnChar function like this.
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
char szBuffer[100] = {0};
short int nCounter = 0;
short int iTemp = 0;
int iStartChar = 0;
int iEndChar = 0;
if(nChar != VK_BACK && nChar != VK_TAB )
{
if(nChar != '.' (nChar < '0' || nChar > '9')
&& (nChar < 'a' || nChar > 'z')&&(nChar < 'A' || nChar > 'Z'))
{
return;
}
GetWindowText((LPTSTR)szBuffer, sizeof(szBuffer));
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Do you have an aversion against isalpha() and isdigit() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi all,
I m using a ListCtrl of Report View Type in dialog boxes and FormView,
I want to resize the last column of List Control according to size of dilog box and formview.
please tell me how can i do this.
if possible please explain with example.
thank 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
|
|
|
|
|
"_$h@nky_" wrote: I want to resize the last column of List Control...
Use the list control's SetColumnWidth() method.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
SetColumnWidth(),use for fix width i want to resize the last coloumn as ListCtrl resize.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: ...i want to resize the last coloumn as ListCtrl resize.
And you use SetColumnWidth() for this.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi All,
If i try to print or preview print, the image gets tilted vertically.
I have set the mapping modes all properly. I think there is a problem some where else.
And fyi - i use CImage Class and BitBlt function with SRCCOPY flag to display my image.
And my mapping mode is MM_LOENGLISH.
Kindly help!
Priya Sundar
|
|
|
|
|
I want to add a button to accept files.
I had set the "Accept Files" property of the button to be True.
But how do I receive the message when I drag a file to the button?
|
|
|
|
|
Create a class for that button derived from CButton. And inside that class handle the WM_DROPFILES message.
|
|
|
|
|
Hi all
I know its windows forum . But I have a doubt : What is the equivalent of _set_new_handler() in unix GCC ? When I tried including it its not compiling . I have included <new> also .
redindian
|
|
|
|
|
|
Ok, I have to do 3 programs for school and I am completely lost on how to start either of them off. If somebody could help me I would greatly appreciate it. Here is the info about the programs.
1. Population
Create a New Project called YourLastnamePopulation.
In a population, the birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data:
· The starting size of a population
· The annual birth rate
· The annual death rate
· The number of years to display
Write a function that calculates the size of the population for a year. The formula is
N = P + BP + DP
Where N is the new population size, P is the previous population size, B is the birth rate, and D is the death rate.
Input Validation: Do not accept numbers less than 2 for the starting size. Do not accept negative numbers for birth rate or death rate. Do not accept numbers less than 1 for the number of years.
2. Lowest Score Drop
Create a New Project called YourLastnameLowestScore.
Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions:
· void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called from main once for each of the five scores to be entered.
· void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores.
· int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop.
Input Validation: Do not accept test scores lower than 0 or higher than 100.
3. Overloaded Hospital
Create a New Project called YourLastnameHospital.
Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient, the following data should be entered:
· The number of days spent in the hospital
· The daily rate
· Hospital medication charges
· Charges for hospital services (lab tests, etc.)
The program should ask for the following data if the patient was an out-patient:
· Charges for hospital services (lab tests, etc.)
· Hospital medication charges
The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other function accepts arguments for out-patient information. Both functions should return the total charges.
Input Validation: Do not accept negative numbers for any data.
Again I would appreciate if someone could start me on the right path to completing these programs
|
|
|
|