65.9K
CodeProject is changing. Read more.
Home

CEditMoeda

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.25/5 (3 votes)

Oct 23, 2002

viewsIcon

60151

downloadIcon

846

A CEdit enhancement for efficient currency capturing.

Demonstration of CEditMoeda

Introduction

At first, sorry if my English isn't very well. The CEditMoeda allows to capture currency values with a CEdit.

To facilitate the usage, the control was sub-classed from CFocusEditCtrl, created by James R. Twine.

Background

The idea of this edit control came from the system of electronic attendance in my country. While the user is typing the value, the zeros and decimal separators are shown at the edit control.

Using the code

The code is too simple, but has 3 details.

  1. Create and initialize a double to receive the captured value (create at the class, but do not use the Add Variable at Class Wizard
  2. Register a double to receive the typed value
    BOOL CEditMoedaDemoDlg::OnInitDialog()
    {
        CDialog::OnInitDialog();
        // TODO: Add extra initialization here
    
        //Register the DOUBLE with control
        m_EditMoedaCtr.RegistraDouble(m_Valor);
    
        return TRUE;  // return TRUE  unless you set the focus to a control
    }
  3. Include one line to send the typed value
    void CEditMoedaDemoDlg::DoDataExchange(CDataExchange* pDX)
    {
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CEditMoedaDemoDlg)
        DDX_Control(pDX, IDC_EditMoeda, m_EditMoedaCtr);
        //}}AFX_DATA_MAP
        m_EditMoedaCtr.Update();
    }
  4. To facilitate the creation and usage of the CEdtiMoeda, specify the currency symbol by the variable m_SimboloMonetario.

Problems

Until now, I can't move the caret to the end fo the text. If someone can obtain this code, please send me an e-mail.