📄 basicsettingdlg.cpp
字号:
// BasicSettingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "EcoPowerMeter.h"
#include "BasicSettingDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBasicSettingDlg dialog
CBasicSettingDlg::CBasicSettingDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBasicSettingDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBasicSettingDlg)
//}}AFX_DATA_INIT
}
void CBasicSettingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBasicSettingDlg)
DDX_Control(pDX, IDC_COMBO1, m_comboPort);
DDX_Control(pDX, IDC_CHECK8, m_checkItem8);
DDX_Control(pDX, IDC_CHECK7, m_checkItem7);
DDX_Control(pDX, IDC_CHECK6, m_checkItem6);
DDX_Control(pDX, IDC_CHECK5, m_checkItem5);
DDX_Control(pDX, IDC_CHECK4, m_checkItem4);
DDX_Control(pDX, IDC_CHECK3, m_checkItem3);
DDX_Control(pDX, IDC_CHECK2, m_checkItem2);
DDX_Control(pDX, IDC_CHECK1, m_checkItem1);
DDX_Control(pDX, IDC_EDIT9, m_editCustomerID);
DDX_Control(pDX, IDC_EDIT8, m_editBranch8);
DDX_Control(pDX, IDC_EDIT7, m_editBranch7);
DDX_Control(pDX, IDC_EDIT6, m_editBranch6);
DDX_Control(pDX, IDC_EDIT5, m_editBranch5);
DDX_Control(pDX, IDC_EDIT4, m_editBranch4);
DDX_Control(pDX, IDC_EDIT3, m_editBranch3);
DDX_Control(pDX, IDC_EDIT2, m_editBranch2);
DDX_Control(pDX, IDC_EDIT1, m_editBranch1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBasicSettingDlg, CDialog)
//{{AFX_MSG_MAP(CBasicSettingDlg)
ON_BN_CLICKED(IDC_BUTTON2, OnButtonSetting)
ON_BN_CLICKED(IDC_BUTTON1, OnButtonReading)
ON_BN_CLICKED(IDC_BUTTON3, OnButtonClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBasicSettingDlg message handlers
BOOL CBasicSettingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strPort,strCustomerID,strBranch,strFileBranch;
//the variable of the system
CEdit *m_editBranch[D_KYOKUNUMS]={&m_editBranch1,&m_editBranch2,&m_editBranch3,&m_editBranch4,
&m_editBranch5,&m_editBranch6,&m_editBranch7,&m_editBranch8};
int m_idcCheck[D_KYOKUNUMS] = {IDC_CHECK1,IDC_CHECK2,IDC_CHECK3,IDC_CHECK4,
IDC_CHECK5,IDC_CHECK6,IDC_CHECK7,IDC_CHECK8};
//set the parameter of the dialog
GetPrivateProfileString("ConfigSet","Port","",strPort.GetBuffer(MAX_PATH),MAX_PATH,".\\ConfigSet.ini");
GetPrivateProfileString("ConfigSet","CustomerID","",strCustomerID.GetBuffer(MAX_PATH),MAX_PATH,".\\ConfigSet.ini");
m_comboPort.SetWindowText(strPort);
m_editCustomerID.SetWindowText(strCustomerID);
for(int i=1; i<D_KYOKUNUMS+1; i++)
{
TRACE("i==%d\n",i);
strBranch.Format("strBranch%d",i);
strFileBranch.Format("Branch%d",i);
GetPrivateProfileString("ConfigSet",strFileBranch,"",strBranch.GetBuffer(MAX_PATH),MAX_PATH,".\\ConfigSet.ini");
if(!strBranch.IsEmpty()&&strBranch!="")
{
m_editBranch[i-1]->SetWindowText(strBranch);
((CButton*)(GetDlgItem( m_idcCheck[i-1] )))->SetCheck(1); //IDC_CHECK is ID for control
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CBasicSettingDlg::OnButtonSetting()
{
// TODO: Add your control notification handler code here
CString strPort,strCustomerID,strBranch,strFileBranch;
//the variable of the system
CEdit *m_editBranch[D_KYOKUNUMS]={&m_editBranch1,&m_editBranch2,&m_editBranch3,&m_editBranch4,
&m_editBranch5,&m_editBranch6,&m_editBranch7,&m_editBranch8};
CButton *m_checkItem[D_KYOKUNUMS]={&m_checkItem1,&m_checkItem2,&m_checkItem3,&m_checkItem4,
&m_checkItem5,&m_checkItem6,&m_checkItem7,&m_checkItem8};
//put the parameter which are needed to the file
m_comboPort.GetWindowText(strPort);
if(!strPort.IsEmpty()&&strPort!="")
{
::WritePrivateProfileString("ConfigSet","Port",strPort,".\\ConfigSet.ini");
}
else
{
AfxMessageBox("ポート選択してください!");
return;
}
m_editCustomerID.GetWindowText(strCustomerID);
if(!strCustomerID.IsEmpty()&&strCustomerID!="")
{
::WritePrivateProfileString("ConfigSet","CustomerID",strCustomerID,".\\ConfigSet.ini");
}
else
{
AfxMessageBox("カスタマID選択してください!");
return;
}
for(int i=1; i<D_KYOKUNUMS+1; i++)
{
strBranch.Format("strBranch%d",i);
strFileBranch.Format("Branch%d",i);
m_editBranch[i-1]->GetWindowText(strBranch);
if(!strBranch.IsEmpty()&&strBranch!="")
{
if(m_checkItem[i-1]->GetCheck() == BST_CHECKED)
{
::WritePrivateProfileString("ConfigSet",strFileBranch,strBranch,".\\ConfigSet.ini");
}
else
{
AfxMessageBox("チェクボクスに選択してください!");
return;
}
}
else if(strBranch.IsEmpty()||strBranch=="")
{
if(m_checkItem[i-1]->GetCheck() == BST_UNCHECKED)
{
::WritePrivateProfileString("ConfigSet",strFileBranch,strBranch,".\\ConfigSet.ini");
}
else
{
AfxMessageBox("エディットボクスに記入してください!");
return;
}
}
}
AfxMessageBox("設定成功!");
CDialog::OnCancel();
}
void CBasicSettingDlg::OnButtonReading()
{
// TODO: Add your control notification handler code here
CString strPort,strCustomerID,strBranch,strFileBranch;
//the variable of the system
CEdit *m_editBranch[D_KYOKUNUMS]={&m_editBranch1,&m_editBranch2,&m_editBranch3,&m_editBranch4,
&m_editBranch5,&m_editBranch6,&m_editBranch7,&m_editBranch8};
int m_idcCheck[D_KYOKUNUMS] = {IDC_CHECK1,IDC_CHECK2,IDC_CHECK3,IDC_CHECK4,
IDC_CHECK5,IDC_CHECK6,IDC_CHECK7,IDC_CHECK8};
//clear moment parameter
m_comboPort.SetWindowText("");
m_editCustomerID.SetWindowText("");
for(int j=1; j<D_KYOKUNUMS+1; j++)
{
m_editBranch[j-1]->SetWindowText("");
((CButton*)(GetDlgItem( m_idcCheck[j-1] )))->SetCheck(0); //IDC_CHECK is ID for control
}
//read the file, and put the parameter to the dialog
GetPrivateProfileString("ConfigSet","Port","",strPort.GetBuffer(MAX_PATH),MAX_PATH,".\\ConfigSet.ini");
GetPrivateProfileString("ConfigSet","CustomerID","",strCustomerID.GetBuffer(MAX_PATH),MAX_PATH,".\\ConfigSet.ini");
m_comboPort.SetWindowText(strPort);
m_editCustomerID.SetWindowText(strCustomerID);
for(int i=1; i<D_KYOKUNUMS+1; i++)
{
TRACE("i==%d\n",i);
strBranch.Format("strBranch%d",i);
strFileBranch.Format("Branch%d",i);
GetPrivateProfileString("ConfigSet",strFileBranch,"",strBranch.GetBuffer(MAX_PATH),MAX_PATH,".\\ConfigSet.ini");
if(!strBranch.IsEmpty()&&strBranch!="")
{
m_editBranch[i-1]->SetWindowText(strBranch);
((CButton*)(GetDlgItem( m_idcCheck[i-1] )))->SetCheck(1); //IDC_CHECK is ID for control
}
}
}
void CBasicSettingDlg::OnButtonClose()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -