📄 sortshow.cpp
字号:
// SortShow.cpp : implementation file
//
#include "stdafx.h"
#include "fert2000.h"
#include "SortShow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern RTU Rtus[MAX_RTU_NUM];
extern CHANNEL Channels[MAX_CHANNEL_NUM];
/////////////////////////////////////////////////////////////////////////////
// CSortShow dialog
CSortShow::CSortShow(CWnd* pParent /*=NULL*/)
: CDialog(CSortShow::IDD, pParent)
{
//{{AFX_DATA_INIT(CSortShow)
m_EndCode = _T("");
m_StartCode = _T("");
//}}AFX_DATA_INIT
StartCode = 0;
EndCode = 0;
CurRtuNo = 0;
Confirm = false;
}
void CSortShow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSortShow)
DDX_Text(pDX, IDC_END_CODE, m_EndCode);
DDV_MaxChars(pDX, m_EndCode, 2);
DDX_Text(pDX, IDC_START_CODE, m_StartCode);
DDV_MaxChars(pDX, m_StartCode, 2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSortShow, CDialog)
//{{AFX_MSG_MAP(CSortShow)
ON_BN_CLICKED(IDC_KWHBUTTON, OnKwhbutton)
ON_BN_CLICKED(IDC_YCBUTTON, OnYcbutton)
ON_BN_CLICKED(IDC_YXBUTTON, OnYxbutton)
ON_BN_CLICKED(IDC_ALLBUTTON, OnAllbutton)
ON_EN_CHANGE(IDC_END_CODE, OnChangeEndCode)
ON_EN_CHANGE(IDC_START_CODE, OnChangeStartCode)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSortShow message handlers
BOOL CSortShow::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_StartCode.Format("%X",StartCode);
m_EndCode.Format("%X",EndCode);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSortShow::OnKwhbutton()
{
StartCode = Rtus[CurRtuNo].ProtocolStamp[2];
if (Channels[Rtus[CurRtuNo].RtuChNo].Protocol == 0)
EndCode = 0xdf;
else if (Channels[Rtus[CurRtuNo].RtuChNo].Protocol == 2 || Channels[Rtus[CurRtuNo].RtuChNo].Protocol == 3)
EndCode = 0xcf;
m_StartCode.Format("%X",StartCode);
m_EndCode.Format("%X",EndCode);
UpdateData(FALSE);
}
void CSortShow::OnYcbutton()
{
StartCode = 0x0;
EndCode = 0x7f;
m_StartCode.Format("%X",StartCode);
m_EndCode.Format("%X",EndCode);
UpdateData(FALSE);
}
void CSortShow::OnYxbutton()
{
StartCode = Rtus[CurRtuNo].ProtocolStamp[1];
EndCode = 0xff;
m_StartCode.Format("%X",StartCode);
m_EndCode.Format("%X",EndCode);
UpdateData(FALSE);
}
void CSortShow::OnAllbutton()
{
StartCode = 0;
EndCode = 0xff;
m_StartCode.Format("%X",StartCode);
m_EndCode.Format("%X",EndCode);
UpdateData(FALSE);
}
void CSortShow::OnOK()
{
UpdateData(TRUE);
DWORD Temp;
sscanf(m_StartCode.GetBuffer(3),"%X",&Temp);
StartCode = (BYTE)Temp;
sscanf(m_EndCode.GetBuffer(3),"%X",&Temp);
EndCode = (BYTE)Temp;
Confirm = true;
CDialog::OnOK();
}
void CSortShow::OnChangeEndCode()
{
UpdateData(TRUE);
char *str = m_EndCode.LockBuffer();
if (('0'<=str[0])&&(str[0]<='9') || ('a'<=str[0])&&(str[0]<='f') || ('A'<=str[0])&&(str[0]<='F') || !str[0])
{
if (('0'<=str[1])&&(str[1]<='9') || ('a'<=str[1])&&(str[1]<='f') || ('A'<=str[1])&&(str[1]<='F') || !str[1]);
else str[1] = 0;
}else str[0] = 0;
m_EndCode.UnlockBuffer();
Rtus[CurRtuNo].ModifyFlag = -1;
UpdateData(FALSE);
}
void CSortShow::OnChangeStartCode()
{
UpdateData(TRUE);
char *str = m_StartCode.GetBufferSetLength(4);
if (('0'<=str[0])&&(str[0]<='9') || ('a'<=str[0])&&(str[0]<='f') || ('A'<=str[0])&&(str[0]<='F') || !str[0])
{
if (('0'<=str[1])&&(str[1]<='9') || ('a'<=str[1])&&(str[1]<='f') || ('A'<=str[1])&&(str[1]<='F') || !str[1]);
else str[1] = 0;
}else str[0] = 0;
Rtus[CurRtuNo].ModifyFlag = -1;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -