Numeric Edit Control

In my application I needed an edit control which accepts only numeric numbers. In many science applications this is indispensable, but it is actually not implemented in MS-Visual C/C++. It is not difficult to implement this control and I see that some people implemented it. In my own code, some new features were enriched as error messages and range defines, etc.

Anyhow, my work is in progress...



class CNumEdit : public CEdit
{
public:
 CNumEdit();
 virtual ~CNumEdit();

public:
 enum {VALID = 0x00, OUT_OF_RANGE = 0x01, INVALID_CHAR = 0x02};
 virtual void Verbose(BOOL v);
 virtual BOOL Verbose();
 virtual int IsValid();
 virtual int IsValid(const CString &str);
 virtual void SetValue(float val);
 virtual float GetValue();
 virtual void GetRange(float &max, float &min);
 virtual void SetRange(float max, float min);

protected:
 BOOL m_Verbose;
 float m_Delta, m_MinValue, m_MaxValue;

 //{{AFX_MSG(CNumEdit)
 afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
 //}}AFX_MSG
}


Download demo project - 32 KB



Comments

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • In this webinar, IDC featured speaker Steve Conway, Vice President of High Performance Computing, will present an update on the global x86 HPC cluster market. The presentation will include IDC's five-year forecast for the medium- to large-scale technical computing and data analysis emerging markets by systems, processors and application middleware. Cray's featured speaker, John Lee, Vice President of Cray Cluster Advanced Technology Systems, will present the new Cray® CS400™ cluster series based on …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds