I wrote this control to replace the boring edit controls we were using for entering numbers. I have included source files, a demo project, and a demo executable for this control.
I hope someone else can get some use out of this code, too. :-)
How to include in your project
- Copy NumEdit.cpp and NumEdit.h into your project directory.
- Add NumEdit.cpp and NumEdit.h to your project.
How to use
- Create an edit control on your dialog.
- Declare a variable in your dialog class, like this:
- In OnInitDialog, call SubclassDlgItem, like this:
m_NumericEdit.SubclassDlgItem(IDC_NUMERIC_EDIT, this); // Use your edit control ID here
- Set the prefix, suffix, # decimals, and whether commas should be displayed using the following member functions:
void SetAttributes(short NumDecimalPlaces, BOOL DisplayCommas = TRUE);
void SetPrefix(CString Prefix);
void SetSuffix(CString Suffix);
- Set (optional) and retrieve the numeric value within your dialog as needed using the following member functions:
void SetNumericValue(double NumericValue);