Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

Number, Currency, Percentage Edit Control

Rate me:
Please Sign up or sign in to vote.
4.38/5 (9 votes)
4 Oct 2000 106.1K   4.5K   31  
Edit Controls that provide masking, formatting and validating for number, currency, percentage values.
//--------------------------------------------------------------------------------------/
//	Header File

//	Class:			CPercentageEdit			
//	Base Class:		CNumEdit

//	File:			PercentageEdit.h		

//	Revision:		A						
//	Date:			17 August 2000
//  Designed;		Ian J Hart	
//--------------------------------------------------------------------------------------/

#ifndef __PERCENTAGEEDIT_H__
#define __PERCENTAGEEDI_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//--------------------------------------------------------------------------------------/

#include "NumEdit.h"

class CPercentageEdit : public CNumEdit  
{
public:
// 1 - Construction - /////////////////////////////////////////////////

	CPercentageEdit();

// 2 - Destruction - /////////////////////////////////////////////////

	virtual ~CPercentageEdit();

protected:
// 3 - Message Map Functions - /////////////////////////////////////////

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

	DECLARE_MESSAGE_MAP()

//	4 - Class Member Variables - ///////////////////////////////////////
private:

	CString m_strPercentage;
	TCHAR	m_chPercentage_Symbol;

//	5 - Class Member Functions - ///////////////////////////////////////
private:
	void Update();

	CString Number_To_Percentage(double fNumber);


//	6 - Class Creation/Initialisation - /////////////////////////////////

public:

	void Init ( double	fNumber			  = 0.00,
				int		dPrecision		  = 2,
				bool	bNeg_Values		  = true);

	void Set_Data(double fNumber,	
				  int	 dPrecision,
				  bool	 bNeg_Values);
								 
// 7 - Interface - ///////////////////////////////////////////////////////

public:

	CString Get_Percentage_Text();

	double	Get_Number();
	void	Set_Number(double fNumber);
};
#endif

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions