// InputMemberno2.cpp : implementation file
//

#include "stdafx.h"
#include "ylgl.h"
#include "InputMemberno2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// InputMemberno2 dialog
InputMemberno2::InputMemberno2(CWnd* pParent /*=NULL*/)
	: CDialog(InputMemberno2::IDD, pParent)
{
	//{{AFX_DATA_INIT(InputMemberno2)
	m_memberno = _T("");
	m_point = _T("");
	//}}AFX_DATA_INIT
}

void InputMemberno2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(InputMemberno2)
	DDX_Control(pDX, IDC_EDIT2, m_editnum);
	DDX_Text(pDX, IDC_EDIT1, m_memberno);
	DDX_Text(pDX, IDC_EDIT2, m_point);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(InputMemberno2, CDialog)
	//{{AFX_MSG_MAP(InputMemberno2)
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// InputMemberno2 message handlers

void InputMemberno2::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	m_point.TrimLeft ();
	m_point.TrimRight ();
	if(	atoi(m_point)==0)
		return;
 
 
	CDialog::OnOK ();
}

BOOL InputMemberno2::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL InputMemberno2::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	return CDialog::PreTranslateMessage(pMsg);
	if(pMsg->message==WM_KEYDOWN)
	{
		switch (pMsg->wParam)
		{
			if(GetFocus()!=GetDlgItem(IDC_EDIT1))return CDialog::PreTranslateMessage(pMsg);
		case '0':
		case VK_NUMPAD0:
			m_input+="0";
			CheckInput();
			break;
		case '1':
		case VK_NUMPAD1:
			m_input+="1";
			CheckInput();
			break;
		case '2':
		case VK_NUMPAD2:
			m_input+="2";
			CheckInput();
			break;
		case '3':
		case VK_NUMPAD3:
			m_input+="3";
			CheckInput();
			break;
		case '4':
		case VK_NUMPAD4:
			m_input+="4";
			CheckInput();
			break;
		case '5':
		case VK_NUMPAD5:
			m_input+="5";
			CheckInput();
			break;
		case '6':
		case VK_NUMPAD6:
			m_input+="6";
			CheckInput();
			break;
		case '7':
		case VK_NUMPAD7:
			m_input+="7";
			CheckInput();
			break;
		case '8':
		case VK_NUMPAD8:
			m_input+="8";
			CheckInput();
			break;
		case '9':
		case VK_NUMPAD9:
			m_input+="9";
			CheckInput();
			break;
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}

void InputMemberno2::CheckInput()
{
  	if(m_input.GetLength ()>=6)
	{
	 	m_input=m_input.Right (6);
		m_memberno=m_input.Left (5);
	    UpdateData(false);
	}
}

void InputMemberno2::OnChangeEdit1() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	UpdateData();
	m_input=m_memberno;
 
	// TODO: Add your control notification handler code here
	
}