config.cpp
来自「一个使用ActiveX实现的串口通讯测试程序」· C++ 代码 · 共 217 行
CPP
217 行
// Config.cpp : implementation file
//
#include "stdafx.h"
#include "CIT Label Print.h"
#include "Config.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CWnd * m_pWnd;
/////////////////////////////////////////////////////////////////////////////
// CConfig dialog
CConfig::CConfig(CWnd* pParent /*=NULL*/)
: CDialog(CConfig::IDD, pParent)
{
//{{AFX_DATA_INIT(CConfig)
m_area_x = _T("");
m_area_y = _T("");
m_label_x = _T("");
m_label_y = _T("");
m_mfg_x = _T("");
m_mfg_y = _T("");
m_ser_x = _T("");
m_ser_y = _T("");
m_time_x = _T("");
m_time_y = _T("");
m_orig_x = _T("");
m_orig_y = _T("");
m_hs_version = _T("");
m_mfgid = _T("");
m_model = _T("");
m_bk_version_item = -1;
m_check_database = FALSE;
m_product_area_info = _T("");
//}}AFX_DATA_INIT
}
void CConfig::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CConfig)
DDX_Control(pDX, IDC_BK_VERSION, m_bk_version_control);
DDX_Text(pDX, IDC_AREA_X, m_area_x);
DDX_Text(pDX, IDC_AREA_Y, m_area_y);
DDX_Text(pDX, IDC_LABEL_X, m_label_x);
DDX_Text(pDX, IDC_LABEL_Y, m_label_y);
DDX_Text(pDX, IDC_MFG_X, m_mfg_x);
DDX_Text(pDX, IDC_MFG_Y, m_mfg_y);
DDX_Text(pDX, IDC_SER_X, m_ser_x);
DDX_Text(pDX, IDC_SER_Y, m_ser_y);
DDX_Text(pDX, IDC_TIME_X, m_time_x);
DDX_Text(pDX, IDC_TIME_Y, m_time_y);
DDX_Text(pDX, IDC_ORIGINAL_X, m_orig_x);
DDX_Text(pDX, IDC_ORIGINAL_Y, m_orig_y);
DDX_Text(pDX, IDC_HS_VERSION, m_hs_version);
DDX_Text(pDX, IDC_MFGID, m_mfgid);
DDX_Text(pDX, IDC_MODEL, m_model);
DDX_CBIndex(pDX, IDC_BK_VERSION, m_bk_version_item);
DDX_Check(pDX, IDC_CHECKDATABASE, m_check_database);
DDX_Text(pDX, IDC_PRODUCT_AREA_INFO, m_product_area_info);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CConfig, CDialog)
//{{AFX_MSG_MAP(CConfig)
ON_CBN_SELCHANGE(IDC_BK_VERSION, OnSelchangeBkVersion)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConfig message handlers
void CConfig::OnOK()
{
// TODO: Add extra validation here
char m_path_buf[1000] = "";
CString m_set_path;
GetCurrentDirectory(1000,m_path_buf);
m_set_path = m_path_buf;
m_set_path = m_set_path + "\\Setting.ini";
// TODO: Add extra validation here
UpdateData(TRUE);
m_bk_version_control.GetLBText(m_bk_version_item,m_bk_version);
// AfxMessageBox(m_bk_version);
// WritePrivateProfileString("Setting","model",m_model,m_set_path);
WritePrivateProfileString("Setting","original_x",m_orig_x,m_set_path);
WritePrivateProfileString("Setting","original_y",m_orig_y,m_set_path);
WritePrivateProfileString("Setting","label_x",m_label_x,m_set_path);
WritePrivateProfileString("Setting","label_y",m_label_y,m_set_path);
WritePrivateProfileString("Setting","serial_x",m_ser_x,m_set_path);
WritePrivateProfileString("Setting","serial_y",m_ser_y,m_set_path);
WritePrivateProfileString("Setting","mfg_x",m_mfg_x,m_set_path);
WritePrivateProfileString("Setting","mfg_y",m_mfg_y,m_set_path);
WritePrivateProfileString("Setting","time_x",m_time_x,m_set_path);
WritePrivateProfileString("Setting","time_y",m_time_y,m_set_path);
WritePrivateProfileString("Setting","area_x",m_area_x,m_set_path);
WritePrivateProfileString("Setting","area_y",m_area_y,m_set_path);
WritePrivateProfileString("Setting","product_area_info",m_product_area_info,m_set_path);
//
AfxGetApp()->WriteProfileString("Config","bk_version",m_bk_version);
AfxGetApp()->WriteProfileString("Config","model",m_model);
AfxGetApp()->WriteProfileString("Config","hs_version",m_hs_version);
AfxGetApp()->WriteProfileString("Config","mfg_id",m_mfgid);
AfxGetApp()->WriteProfileInt("Config","check_database",m_check_database);
//
CString m_config_str;
m_config_str.Format("Config%d",m_bk_version_item+1);
WritePrivateProfileString(m_config_str,"model",m_model,m_set_path);
WritePrivateProfileString(m_config_str,"MFG_ID",m_mfgid,m_set_path);
WritePrivateProfileString(m_config_str,"H/S_Version",m_hs_version,m_set_path);
//
CDialog::OnOK();
m_pWnd->SendMessage(WM_SHOW_MESSAGE,0,0);
}
void CConfig::OnSelchangeBkVersion()
{
// TODO: Add your control notification handler code here
char m_path_buf[1000] = "";
CString m_set_path;
GetCurrentDirectory(1000,m_path_buf);
m_set_path = m_path_buf;
m_set_path = m_set_path + "\\Setting.ini";
//
char bk_version_buf[10] = "";
char model_buf[20] = "";
char mfgid_buf[10] = "";
char hs_version_buf[10] = "";
///
/////////
UpdateData(TRUE);
CString m_config_str;
m_bk_version_control.GetLBText(m_bk_version_item,m_bk_version);
for(int i=1;i<=m_config_num;i++)
{
m_config_str.Format("Config%d",i);
GetPrivateProfileString(m_config_str,"Board_Kit_Version",NULL,bk_version_buf,10,m_set_path);
if(m_bk_version.Compare(bk_version_buf) == 0)
{
GetPrivateProfileString(m_config_str,"model",NULL,model_buf,20,m_set_path);
GetPrivateProfileString(m_config_str,"MFG_ID",NULL,mfgid_buf,10,m_set_path);
GetPrivateProfileString(m_config_str,"H/S_Version",NULL,hs_version_buf,10,m_set_path);
m_model = model_buf;
m_mfgid = mfgid_buf;
m_hs_version = hs_version_buf;
}
}
UpdateData(FALSE);
}
void CConfig::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CConfig::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
char m_path_buf[1000] = "";
CString m_set_path;
GetCurrentDirectory(1000,m_path_buf);
m_set_path = m_path_buf;
m_set_path = m_set_path + "\\Setting.ini";
//
char bk_version_buf[10] = "";
char model_buf[20] = "";
char mfgid_buf[10] = "";
char hs_version_buf[10] = "";
///
DWORD m_a;
m_config_num = 1;
//
CString m_config_str;
m_bk_version_control.ResetContent();
do {
m_config_str.Format("Config%d",m_config_num);
m_a = GetPrivateProfileString(m_config_str,"Board_Kit_Version",NULL,bk_version_buf,10,m_set_path);
if(m_a == 0)
break;
// str = bk_version_buf;
m_bk_version_control.InsertString(-1,bk_version_buf);
if(AfxGetApp()->GetProfileString("Config","bk_version",NULL).Compare(bk_version_buf) == 0)
{
m_bk_version_item = m_config_num-1;
// m_bk_version_control.SetTopIndex(i-1);
GetPrivateProfileString(m_config_str,"model",NULL,model_buf,20,m_set_path);
GetPrivateProfileString(m_config_str,"MFG_ID",NULL,mfgid_buf,10,m_set_path);
GetPrivateProfileString(m_config_str,"H/S_Version",NULL,hs_version_buf,10,m_set_path);
m_model = model_buf;
m_mfgid = mfgid_buf;
m_hs_version = hs_version_buf;
}
m_config_num++;
} while(m_config_num<20);
m_check_database = AfxGetApp()->GetProfileInt("Config","check_database",1);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?