Problem source:
Up and down controls are usually used with an input digital EDIT control, and general numbers should be an integer, recently requiring the EDIT to enter a decimal in the project development. This way, the original control is to do some changes. For example, in the current Edit box is 4.3 should be 4 and 5 after pressing the upper and lower controls.
Change ideas:
Write a class CSPinButtonCtrl inherited CSPinButtonCtrl, responding to ONLBUTTONDOWN, in which the base point of the upper and lower controls are reset by the numbers in the editing control related to the upper and lower controls.
ONLBUTTONDOWN function:
void CMySpinButtonCtrl :: OnLButtonDown (UINT nFlags, CPoint point) {// TODO: Add your message handler code here and / or call default int nRow; int nUpper; CMySpinButtonCtrl :: GetRange (nRow, nUpper); / * * Analyzing edit box Whether the input is legal * / cstring strnum; cmyspinbuttonctrl :: getBuddy () -> getWindowText (Strnum); if (g_isnumber (strnum) == false {MessageBox ("Please enter the legal number"); return;} else { CRECT RECT; CMYSPINBUTTONCTRL :: getWindowRect (& Re); if (strnum.find ('.')> 0) {Int ndotpos = strnum.find ('.'); Int NLENGTH = Strnum.getlength (); strnum = strnum. Left (ndotpos 1); int POS = ATOI (Strnum); if (Point.Y CSPINBUTTONCTRL :: ONLBUTTONDOWN (NFLAGS, POINT); } // where g_isnumber is a function that determines whether a string is a number (can be a decimal)