// DevSNDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Demo.h"
#include "DevSNDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDevSNDlg dialog


CDevSNDlg::CDevSNDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDevSNDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDevSNDlg)
	//}}AFX_DATA_INIT
}


void CDevSNDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDevSNDlg)
	DDX_Control(pDX, IDC_EDIT_DevSN, m_edit_devsn);
	DDX_Control(pDX, IDC_Btn_OK, m_btn_ok);
	DDX_Control(pDX, IDC_btn_cancel, m_btn_cancel);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDevSNDlg, CDialog)
	//{{AFX_MSG_MAP(CDevSNDlg)
	ON_BN_CLICKED(IDC_Btn_OK, OnBtnOK)
	ON_BN_CLICKED(IDC_btn_cancel, Onbtncancel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDevSNDlg message handlers

BOOL CDevSNDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_btn_ok.SetIcon(IDI_ICON_OK);
	m_btn_ok.DrawTransparent(TRUE);

	m_btn_cancel.SetIcon(IDI_ICON_CANCEL);
	m_btn_cancel.DrawTransparent(TRUE);
	
	m_edit_devsn.SetWindowText("00000001");
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDevSNDlg::OnBtnOK() 
{
	// TODO: Add your control notification handler code here
	m_edit_devsn.GetWindowText(m_strDevSN);
	if (m_strDevSN.IsEmpty())
	{
		AfxMessageBox("设备序列号不能为空");
		return;
	}
	if (m_strDevSN.GetLength()>32)
	{
		AfxMessageBox("设备序列号应小于32");
		return;
	}
	CDialog::OnOK();	
}

void CDevSNDlg::Onbtncancel() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}
