#CEdit
Here is the Header and CPP file of "MYEdit".
class CFEdit : public CEdit
{
// Construction
public:
CFEdit();
CString Mask; //This is the Picture used to format
the text
CString Incoming; //This is the Typed (NUMBERS
ONLY) characters
CString CFEdit::Merge_Mask(CString raw,CString Picture);
void Init(CString ivalue,CString mask);
public:
virtual ~CFEdit();
protected:
//{{AFX_MSG(CFEdit)
afx_msg UINT OnGetDlgCode();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
This is the CPP File;
#include "stdafx.h"
#include "halstr.h"
#include "fedit.h"
//*****************************************************************************
*************************
//******************************************************************************
************************
//*****************************************************************************
*************************
CFEdit::CFEdit()
{
}
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//******************************************************************************
************************
CFEdit::~CFEdit()
{
}
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//*****************************************************************************
*************************
BEGIN_MESSAGE_MAP(CFEdit, CEdit)
//{{AFX_MSG_MAP(CFEdit)
ON_WM_GETDLGCODE()
ON_WM_KEYDOWN()
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//*****************************************************************************
*************************
void CFEdit::Init(CString ivalue,CString mask)
{
this->SetWindowText(ivalue);
Mask = mask;
Incoming = "";
};
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//*****************************************************************************
*************************
UINT CFEdit::OnGetDlgCode()
{
return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS;
};
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//*****************************************************************************
*************************
CString CFEdit::Merge_Mask(CString raw,CString Picture)
{
};
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//*****************************************************************************
*************************
afx_msg void CFEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ((nChar >= '0') && (nChar <= '9'))
{
//****** "Incoming" is the CString that appears not
Initialized!***************
Incoming += nChar; // <<===This is where It Dies!!!!!
CString Temp = Merge_Mask(Incoming,Mask);
this->SetWindowText(Temp);
}
else
MessageBeep(0);
}
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//*****************************************************************************
*************************
void CFEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
};
//*****************************************************************************
*************************
//*****************************************************************************
*************************
//******************************************************************************
************************