Click here to Skip to main content
15,896,915 members
Articles / Desktop Programming / MFC
Article

CEditMoeda

Rate me:
Please Sign up or sign in to vote.
4.25/5 (3 votes)
22 Oct 2002 60K   846   17   3
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.

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
Web Developer
Brazil Brazil
Programação em C++, com MFC e ObjectARX (AutoCAD) desde 2001. Também conhecimento com ASP e outras linguagens para Web desde 2000. Atualmente desenvolve soluções em .NET (WinForms e WebForms) e SQL Server

Programing C++ with MFC and ObjectARX (AutoCAD) since 2001, also developing ASP.NET (HTML, DHTML, AJAX, JS, VB.NET, C#) and WinForms (C#), both using SQL Server.

Comments and Discussions

 
GeneralCompatibilidade com VC++ 7.0 Pin
Member 57266718-Feb-04 9:59
Member 57266718-Feb-04 9:59 
Olá Augusto,

Tente compilar o demo no VC++ 7.0 e ocorreu a seguinte mensagem de erro:

"c:\temp\EditMoedaDemo\EditMoeda.cpp(35): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CEditMoeda::* )(void)' to 'void (__thiscall CWnd::* )(CWnd *)'"

Você pode me ajudar?
Grato.
Maurício

GeneralSetting the Caret Pos Pin
Neville Franks23-Oct-02 13:17
Neville Franks23-Oct-02 13:17 
GeneralRe: Setting the Caret Pos Pin
Stefan Rehling5-Apr-07 22:51
Stefan Rehling5-Apr-07 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.