Click here to Skip to main content
11,578,739 members (62,815 online)
Click here to Skip to main content
Add your own
alternative version

CFilterEdit: Use Regular Expressions to Filter Your Input

, 3 Oct 2011 CPOL 317.4K 8.2K 245
The definitive approach to filtering input text. Includes configurable error display.
#pragma once
#include "BaseEdit.h"

namespace FilterEdit
{
class CCurrencyEdit : public CBaseEdit
{
public:
	CCurrencyEdit ();
	virtual ~CCurrencyEdit ();
	void CreateToolTip (CWnd *pParent);
	double GetValue () const;

protected:
	void RemoveSeparators (CString &str) const;

private:
	enum e_Currency {ePrefix, eSuffix, ePrefixSpc, eSpcSuffix};
	enum e_NegCurrency {eParenCurrNumParen, eNegCurrNum, eCurrNegNum,
		eCurrNumNeg, eParenNumCurrParen, eNegNumCurr, eNumNegCurr,
		eNumCurrNeg, eNegNumSpcCurr, eNegCurrSpcNum, eNumSpcCurrNeg,
		eCurrSpcNumNeg, eCurrSpcNegNum, eNumNegSpcCurr, eParenCurrSpcNumParen,
		eParenNumSpcCurrParen};

	static bool m_bInitialised;
	static CString m_strCurrency;
	static e_Currency m_eCurrency;
	static e_NegCurrency m_eNegCurrency;
	static CString m_strDecimal;
	static int m_iFractionalDigits;
	static CString m_strSeparator;
	static CString m_strToolTip;
	static CRegEx m_RegEx;
};
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ben Hanson
Software Developer (Senior)
United Kingdom United Kingdom
I started programming in 1983 using Sinclair BASIC, then moving on to Z80 machine code and assembler. In 1988 I programmed 68000 assembler on the ATARI ST and it was 1990 when I started my degree in Computing Systems where I learnt Pascal, C and C++ as well as various academic programming languages (ML, LISP etc.)

I have been developing commercial software for Windows using C++ for 15 years.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150603.1 | Last Updated 3 Oct 2011
Article Copyright 2004 by Ben Hanson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid