📄 sramdlg.cpp
字号:
// SramDlg.cpp : implementation file
//
#include "stdafx.h"
#include "IfsUsb.h"
#include "SramDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSramDlg dialog
CSramDlg::CSramDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSramDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSramDlg)
m_SramDlgEdit1 = _T("");
m_SramDlgEdit2 = _T("");
m_SramDlgEdit3 = _T("");
m_SramDlgEdit4 = _T("");
m_SramDlgEdit5 = _T("");
m_SramDlgEdit6 = _T("");
m_SramDlgEdit7 = _T("");
m_SramDlgEdit8 = _T("");
m_SramDlgAddress = _T("");
//}}AFX_DATA_INIT
}
void CSramDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSramDlg)
DDX_Text(pDX, IDC_EDIT1, m_SramDlgEdit1);
DDX_Text(pDX, IDC_EDIT2, m_SramDlgEdit2);
DDX_Text(pDX, IDC_EDIT3, m_SramDlgEdit3);
DDX_Text(pDX, IDC_EDIT4, m_SramDlgEdit4);
DDX_Text(pDX, IDC_EDIT5, m_SramDlgEdit5);
DDX_Text(pDX, IDC_EDIT6, m_SramDlgEdit6);
DDX_Text(pDX, IDC_EDIT7, m_SramDlgEdit7);
DDX_Text(pDX, IDC_EDIT8, m_SramDlgEdit8);
DDX_Text(pDX, IDC_STATIC_SRAMADDRESS, m_SramDlgAddress);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSramDlg, CDialog)
//{{AFX_MSG_MAP(CSramDlg)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit3)
ON_EN_CHANGE(IDC_EDIT4, OnChangeEdit4)
ON_EN_CHANGE(IDC_EDIT5, OnChangeEdit5)
ON_EN_CHANGE(IDC_EDIT6, OnChangeEdit6)
ON_EN_CHANGE(IDC_EDIT7, OnChangeEdit7)
ON_EN_CHANGE(IDC_EDIT8, OnChangeEdit8)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSramDlg message handlers
/////////////////////////////////////////////////////////////////////////////////
void CSramDlg::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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit1);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit1 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit2()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit2);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit2 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit3()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit3);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit3 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit4()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit4);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit4 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit5()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit5);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit5 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit6()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit6);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit6 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit7()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit7);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit7 = "";
UpdateData(false);
}
}
void CSramDlg::OnChangeEdit8()
{
// 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.
// TODO: Add your control notification handler code here
BOOL bSuccess;
UpdateData(true);
bSuccess = HexCheck(m_SramDlgEdit8);
if (!bSuccess)
{
MessageBox("Must input HEX format number!","Error",MB_OK | MB_ICONWARNING);
m_SramDlgEdit8 = "";
UpdateData(false);
}
}
BOOL CSramDlg::HexCheck(CString m_sStr)
{
int i, iLength;
UCHAR b;
BOOL bSuccess = true;
iLength = m_sStr.GetLength();
if (iLength == 0)
bSuccess = true;
else
{
for (i=0;i<iLength;i++)
{
b = m_sStr.GetAt(i);
if (!((b>=0x30 && b<=0x39) || (b>=0x41 && b<=0x46)))
{
bSuccess = false;
break;
}
}
}
return bSuccess;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -