Effect
Key code
void Cdecimaledit::onchar (UINT NChar, uint nrepcnt, uint nflags) {//Todo:add your message Handler co De here and/or call default///guarantee that the decimal point can only occur once if ((nchar==0x08) | | (nchar==0x10))
, Backspace,delete {Cedit::onchar (NChar, nrepcnt, nflags);
} CString str;
Gets the string GetWindowText (str) in the original edit box; int len = str.
GetLength ();
if (Len >=) {return;
} if (nchar== '. ') {///Wakahara has a decimal point in the string, it is not entered so that you can enter at most one decimal if (str). Find ('. ')!
=-1) {}//otherwise enter this decimal dot else {Cedit::onchar (NChar, nrepcnt, nflags);
} return;
}//Except the decimal point, also allows the input number if ((nchar>= ' 0 ' && nchar<= ' 9 ')) {Cedit::onchar (NChar, nrepcnt, nflags);
}//Other keys do not respond to else {} getwindowtext (str); Len = str.
GetLength ();
if (len >=) {checkwidth (str);
Return
} if (Atoi (str) > 4000000) {AfxMessageBox ("the maximum value must not exceed 4000000");
SetWindowText ("");
Return
} checkwidth (str);
Return }
Project Download:
http://download.csdn.net/detail/ycs34082419900527/9912505 Click to open link