|
C++ Programming |
Download
Source | Download
Sample
Introduction
Two additional classes are provided for demonstration purposes. All the code for handling the prefix and suffix texts are handled in
the abstract base class, so data exchange to a floating point using To implement your own validation classes, simply inherit a new class
from
class TEditAngle : public TEditTimedUpdate
{
protected:
virtual void AdjustValue(CString &__strValue);
public:
TEditAngle();
virtual ~TEditAngle();
DECLARE_MESSAGE_MAP()
};
static const unsigned char szDegrees[] = {(unsigned char)176,0};
TEditAngle::TEditAngle() : TEditTimedUpdate(NULL, (char*)szDegrees)
{
}
TEditAngle::~TEditAngle()
{
}
void TEditAngle::AdjustValue(CString &__strValue)
{
double lfValue;
LPTSTR pStopString;
lfValue = _tcstod(__strValue, &pStopString);
if (lfValue < 0.001)
lfValue = 0.0;
else if (lfValue > 360.0)
lfValue = 360.0;
__strValue.Format("%.2f", lfValue);
}
When the value has been validated, the control sends a There's not too much more to say. I think this is a great class that
is very simple to use and provides a very rich user interface - but then
I'm probably biased ;). It also solves all the problems will allowing
non-integer numeric data entry and validates as the user enters data rather
than waiting for the horrible validation messages created by MFC's |
||
|
|||