98 lines
2.2 KiB
C++
98 lines
2.2 KiB
C++
// KcConfigDlg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "KcCtrl.h"
|
|
#include "resource.h"
|
|
#include "KcConfigDlg.h"
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
// CKcConfigDlg 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(CKcConfigDlg, CDialogEx)
|
|
|
|
CKcConfigDlg::CKcConfigDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialogEx(IDD_CK_CFG_DLG, pParent)
|
|
{
|
|
|
|
}
|
|
|
|
CKcConfigDlg::~CKcConfigDlg()
|
|
{
|
|
}
|
|
|
|
void CKcConfigDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_IPADDRESS1, m_IpAddress);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CKcConfigDlg, CDialogEx)
|
|
ON_BN_CLICKED(IDC_BTN_SETTING, &CKcConfigDlg::OnBnClickedBtnSetting)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CKcConfigDlg 消息处理程序
|
|
|
|
|
|
BOOL CKcConfigDlg::OnInitDialog()
|
|
{
|
|
CDialogEx::OnInitDialog();
|
|
|
|
CString strPort;
|
|
strPort.Format("%d", theApp.m_nControllerPort);
|
|
GetDlgItem(IDC_EDIT_PORT)->SetWindowText(strPort);
|
|
|
|
|
|
CString strIp = theApp.m_strControllerIp;
|
|
int ip_arry[4] = {}; //接收ip的整形数组
|
|
int j;
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
if (i != 3)
|
|
j = strIp.Find('.');//找到分割符号的位置
|
|
else
|
|
j = 4;
|
|
ip_arry[i] = atoi(strIp.Left(j));//转化成整形并赋值给数组
|
|
strIp.Delete(0, j + 1);
|
|
}
|
|
//填入ip地址
|
|
m_IpAddress.SetAddress(ip_arry[0], ip_arry[1], ip_arry[2], ip_arry[3]);
|
|
|
|
|
|
CString iniPath = theApp.m_strModulePath + "\\config.ini";
|
|
|
|
char acAuth[48];
|
|
GetPrivateProfileString("SERVER", "AUTH", "", acAuth, 48, iniPath);
|
|
GetDlgItem(IDC_EDIT_AUTH)->SetWindowText(acAuth);
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
}
|
|
|
|
|
|
void CKcConfigDlg::OnBnClickedBtnSetting()
|
|
{
|
|
unsigned char* ip{};
|
|
DWORD dword;
|
|
m_IpAddress.GetAddress(dword);
|
|
ip = (unsigned char*)&dword;
|
|
theApp.m_strControllerIp.Format("%u.%u.%u.%u", *(ip + 3), *(ip + 2), *(ip + 1), *ip);
|
|
|
|
CString strPort;
|
|
GetDlgItem(IDC_EDIT_PORT)->GetWindowText(strPort);
|
|
CString strAuth;
|
|
GetDlgItem(IDC_EDIT_AUTH)->GetWindowText(strAuth);
|
|
|
|
CString iniPath = theApp.m_strModulePath + "\\config.ini";
|
|
WritePrivateProfileString("SERVER", "IP", theApp.m_strControllerIp, iniPath);
|
|
WritePrivateProfileString("SERVER", "PORT", strPort, iniPath);
|
|
WritePrivateProfileString("SERVER", "AUTH", strAuth, iniPath);
|
|
|
|
theApp.m_nControllerPort = atoi(strPort);
|
|
AfxMessageBox("配置已修改,需要重启插件");
|
|
OnOK();
|
|
}
|