📄 channelsetting.cpp
字号:
// ChannelSetting.cpp : implementation file
//
#include "stdafx.h"
#include "Interface.h"
#include "ChannelSetting.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChannelSetting dialog
CChannelSetting::CChannelSetting(CWnd* pParent /*=NULL*/)
: CDialog(CChannelSetting::IDD, pParent)
{
//{{AFX_DATA_INIT(CChannelSetting)
//}}AFX_DATA_INIT
for(int i=0;i<8;i++)
{
m_name[i]=_T("");
m_hv[i]=_T("");
m_lv[i]=_T("");
m_critical[i]=_T("");
}
}
void CChannelSetting::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChannelSetting)
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_Name_0, m_name[0]);
DDX_Text(pDX, IDC_Name_1, m_name[1]);
DDX_Text(pDX, IDC_Name_2, m_name[2]);
DDX_Text(pDX, IDC_Name_3, m_name[3]);
DDX_Text(pDX, IDC_Name_4, m_name[4]);
DDX_Text(pDX, IDC_Name_5, m_name[5]);
DDX_Text(pDX, IDC_Name_6, m_name[6]);
DDX_Text(pDX, IDC_Name_7, m_name[7]);
DDX_Control(pDX, IDC_Bound_0, m_bound[0]);
DDX_Control(pDX, IDC_Bound_1, m_bound[1]);
DDX_Control(pDX, IDC_Bound_2, m_bound[2]);
DDX_Control(pDX, IDC_Bound_3, m_bound[3]);
DDX_Control(pDX, IDC_Bound_4, m_bound[4]);
DDX_Control(pDX, IDC_Bound_5, m_bound[5]);
DDX_Control(pDX, IDC_Bound_6, m_bound[6]);
DDX_Control(pDX, IDC_Bound_7, m_bound[7]);
DDX_Text(pDX, IDC_Critical_0, m_critical[0]);
DDX_Text(pDX, IDC_Critical_1, m_critical[1]);
DDX_Text(pDX, IDC_Critical_2, m_critical[2]);
DDX_Text(pDX, IDC_Critical_3, m_critical[3]);
DDX_Text(pDX, IDC_Critical_4, m_critical[4]);
DDX_Text(pDX, IDC_Critical_5, m_critical[5]);
DDX_Text(pDX, IDC_Critical_6, m_critical[6]);
DDX_Text(pDX, IDC_Critical_7, m_critical[7]);
DDX_Control(pDX, IDC_Handle_0, m_handle[0]);
DDX_Control(pDX, IDC_Handle_1, m_handle[1]);
DDX_Control(pDX, IDC_Handle_2, m_handle[2]);
DDX_Control(pDX, IDC_Handle_3, m_handle[3]);
DDX_Control(pDX, IDC_Handle_4, m_handle[4]);
DDX_Control(pDX, IDC_Handle_5, m_handle[5]);
DDX_Control(pDX, IDC_Handle_6, m_handle[6]);
DDX_Control(pDX, IDC_Handle_7, m_handle[7]);
DDX_Text(pDX, IDC_HV_0, m_hv[0]);
DDX_Text(pDX, IDC_HV_1, m_hv[1]);
DDX_Text(pDX, IDC_HV_2, m_hv[2]);
DDX_Text(pDX, IDC_HV_3, m_hv[3]);
DDX_Text(pDX, IDC_HV_4, m_hv[4]);
DDX_Text(pDX, IDC_HV_5, m_hv[5]);
DDX_Text(pDX, IDC_HV_6, m_hv[6]);
DDX_Text(pDX, IDC_HV_7, m_hv[7]);
DDX_Text(pDX, IDC_LV_0, m_lv[0]);
DDX_Text(pDX, IDC_LV_1, m_lv[1]);
DDX_Text(pDX, IDC_LV_2, m_lv[2]);
DDX_Text(pDX, IDC_LV_3, m_lv[3]);
DDX_Text(pDX, IDC_LV_4, m_lv[4]);
DDX_Text(pDX, IDC_LV_5, m_lv[5]);
DDX_Text(pDX, IDC_LV_6, m_lv[6]);
DDX_Text(pDX, IDC_LV_7, m_lv[7]);
DDX_Control(pDX, IDC_Operate_0, m_operate[0]);
DDX_Control(pDX, IDC_Operate_1, m_operate[1]);
DDX_Control(pDX, IDC_Operate_2, m_operate[2]);
DDX_Control(pDX, IDC_Operate_3, m_operate[3]);
DDX_Control(pDX, IDC_Operate_4, m_operate[4]);
DDX_Control(pDX, IDC_Operate_5, m_operate[5]);
DDX_Control(pDX, IDC_Operate_6, m_operate[6]);
DDX_Control(pDX, IDC_Operate_7, m_operate[7]);
}
BEGIN_MESSAGE_MAP(CChannelSetting, CDialog)
//{{AFX_MSG_MAP(CChannelSetting)
ON_BN_CLICKED(IDC_BUTTON2, OnSetChannel)
ON_BN_CLICKED(IDC_CHECK25, OnSame)
ON_BN_CLICKED(IDC_BUTTON13, OnQuit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChannelSetting message handlers
void CChannelSetting::OnSetChannel()
{
// TODO: Add your control notification handler code here
HANDLE hFile;
CString buf;
BOOL bRc;
DWORD dwBytesWritten;
hFile = CreateFile (_T("\\Recv.txt"), // Open One.txt.TEXT("D:\\Test\\Recv.txt")
GENERIC_READ|GENERIC_WRITE, // Open for reading
0, // Do not share
NULL, // No security
OPEN_ALWAYS,//CREATE_NEW, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL);
UpdateData(TRUE);
for(int i=0;i<8;i++)
{
bRc =WriteFile (hFile,m_name[i],m_name[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-m_name[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,m_hv[i],m_hv[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-m_hv[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,m_lv[i],m_lv[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-m_lv[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,m_critical[i],m_critical[i].GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-m_critical[i].GetLength()*2,&dwBytesWritten, NULL);
buf.Format(_T("%d"),m_operate[i].GetCheck());
bRc =WriteFile (hFile,buf,buf.GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-buf.GetLength()*2,&dwBytesWritten, NULL);
buf.Format(_T("%d"),m_bound[i].GetCheck());
bRc =WriteFile (hFile,buf,buf.GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-buf.GetLength()*2,&dwBytesWritten, NULL);
buf.Format(_T("%d"),m_handle[i].GetCheck());
bRc =WriteFile (hFile,buf,buf.GetLength()*2,&dwBytesWritten, NULL);
bRc =WriteFile (hFile,"\0",40-buf.GetLength()*2,&dwBytesWritten, NULL);
}
CloseHandle(hFile);
AfxMessageBox(_T("Saved Succeed !"));
CDialog::OnOK();
}
void CChannelSetting::Display()
{
HANDLE hFile;
hFile = CreateFile (_T("\\Recv.txt"), // Open One.txt.
GENERIC_READ|GENERIC_WRITE, // Open for reading
0, // Do not share
NULL, // No security
OPEN_EXISTING,//CREATE_NEW, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL);
DWORD dwBytesRead;
BOOL bRc;
CString temp;
if (hFile == INVALID_HANDLE_VALUE)
{
// Your error-handling code goes here.
AfxMessageBox(_T("Could not Great Recv.TXT"));
return;
}
TCHAR buff1[20];
float temp2;
for(int i=0;i<8;i++)
{
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
m_name[i].Format(_T("%s"),buff1);
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
m_hv[i].Format(_T("%s"),buff1);
//temp2=atof(_T(m_edit2[i]));
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
m_lv[i].Format(_T("%s"),buff1);
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
m_critical[i].Format(_T("%s"),buff1);
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
temp.Format(_T("%s"),buff1);
if(temp.Compare(_T("1"))==0)
m_operate[i].SetCheck(1);
else
m_operate[i].SetCheck(0);
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
temp.Format(_T("%s"),buff1);
if(temp.Compare(_T("1"))==0)
m_bound[i].SetCheck(1);
else
m_bound[i].SetCheck(0);
bRc = ReadFile(hFile,buff1,40, &dwBytesRead, NULL);
temp.Format(_T("%s"),buff1);
if(temp.Compare(_T("1"))==0)
m_handle[i].SetCheck(1);
else
m_handle[i].SetCheck(0);
}
UpdateData(FALSE);
CloseHandle(hFile);
}
BOOL CChannelSetting::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
Display();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChannelSetting::OnSame()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
for(int i=1;i<8;i++)
{
m_name[i].Format(_T("%s%d"),m_name[0],i);
m_lv[i]=m_lv[0];
m_hv[i]=m_hv[0];
m_critical[i]=m_critical[0];
m_operate[i].SetCheck(m_operate[0].GetCheck());
m_bound[i].SetCheck(m_bound[0].GetCheck());
m_handle[i].SetCheck(m_handle[0].GetCheck());
}
UpdateData(FALSE);
}
void CChannelSetting::OnQuit()
{
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -