102 lines
2.1 KiB
C++
102 lines
2.1 KiB
C++
|
// PlcDeviceDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|||
|
//
|
|||
|
|
|||
|
#include "stdafx.h"
|
|||
|
#include "ConfigDlg.h"
|
|||
|
#include "afxdialogex.h"
|
|||
|
#include "PluginPlc.h"
|
|||
|
#include "resource.h"
|
|||
|
|
|||
|
#define TIMER_UPDATE_TOPLC 1
|
|||
|
#define TIMER_UPDATE_TODLG 2
|
|||
|
#define TIMER_UPDATE_FROMPLC 3
|
|||
|
|
|||
|
|
|||
|
// CPlcDeviceDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
|||
|
|
|||
|
IMPLEMENT_DYNAMIC(CConfigDlg, CDialogEx)
|
|||
|
|
|||
|
CConfigDlg::CConfigDlg(CWnd* pParent /*=NULL*/)
|
|||
|
: CDialogEx(IDD_CONFIG_DLG, pParent)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
CConfigDlg::~CConfigDlg()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void CConfigDlg::DoDataExchange(CDataExchange* pDX)
|
|||
|
{
|
|||
|
CDialogEx::DoDataExchange(pDX);
|
|||
|
DDX_Control(pDX, IDC_IPADDRESS, m_ipAddrCtrl);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
BEGIN_MESSAGE_MAP(CConfigDlg, CDialogEx)
|
|||
|
ON_BN_CLICKED(IDC_BTN_SET, &CConfigDlg::OnBnClickedBtnSet)
|
|||
|
|
|||
|
END_MESSAGE_MAP()
|
|||
|
|
|||
|
|
|||
|
// CPlcDeviceDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
BOOL CConfigDlg::OnInitDialog()
|
|||
|
{
|
|||
|
CDialogEx::OnInitDialog();
|
|||
|
|
|||
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
ReadConfigFromIni();
|
|||
|
|
|||
|
|
|||
|
return TRUE; // return TRUE unless you set the focus to a control
|
|||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
|||
|
}
|
|||
|
|
|||
|
void CConfigDlg::ReadConfigFromIni()
|
|||
|
{
|
|||
|
CString strIniPath = theApp.m_strModulePath + "\\config.ini";
|
|||
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
char acValue[32] = "";
|
|||
|
GetPrivateProfileString("CORE", "IP", "", acValue, 32, strIniPath);
|
|||
|
//m_strIpAddr = acValue;
|
|||
|
DWORD dwIP = inet_addr(acValue);
|
|||
|
unsigned char *pIP = (unsigned char*)&dwIP;
|
|||
|
m_ipAddrCtrl.SetAddress(*pIP, *(pIP + 1), *(pIP + 2), *(pIP + 3));
|
|||
|
|
|||
|
|
|||
|
|
|||
|
int nPort = GetPrivateProfileInt("CORE", "PORT", 0, strIniPath);
|
|||
|
CString strPort;
|
|||
|
strPort.Format("%d", nPort);
|
|||
|
GetDlgItem(IDC_EDIT_PORT)->SetWindowText(strPort);
|
|||
|
|
|||
|
|
|||
|
return; // return TRUE unless you set the focus to a control
|
|||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void CConfigDlg::OnBnClickedBtnSet()
|
|||
|
{
|
|||
|
CString strIniPath = theApp.m_strModulePath + "\\config.ini";
|
|||
|
BYTE nFild[4];
|
|||
|
m_ipAddrCtrl.GetAddress(nFild[0], nFild[1], nFild[2], nFild[3]);
|
|||
|
CString strIpAddr;
|
|||
|
strIpAddr.Format("%d.%d.%d.%d", nFild[0], nFild[1], nFild[2], nFild[3]);
|
|||
|
WritePrivateProfileString("CORE", "IP", strIpAddr, strIniPath);
|
|||
|
|
|||
|
CString strPort;
|
|||
|
GetDlgItem(IDC_EDIT_PORT)->GetWindowText(strPort);
|
|||
|
WritePrivateProfileString("CORE", "PORT", strPort, strIniPath);
|
|||
|
|
|||
|
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>.");
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|