88 lines
1.8 KiB
C++
88 lines
1.8 KiB
C++
// ConfigDLg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "QrGuide.h"
|
|
#include "ConfigDLg.h"
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
// CConfigDLg 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(CConfigDLg, CDialogEx)
|
|
|
|
CConfigDLg::CConfigDLg(CWnd* pParent /*=NULL*/)
|
|
: CDialogEx(IDD_CFG_DLG, pParent)
|
|
{
|
|
|
|
}
|
|
|
|
CConfigDLg::~CConfigDLg()
|
|
{
|
|
}
|
|
|
|
void CConfigDLg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_IPADDRESS1, m_IpAddress);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CConfigDLg, CDialogEx)
|
|
ON_BN_CLICKED(IDC_BTN_SETTING, &CConfigDLg::OnBnClickedBtnSetting)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CConfigDLg 消息处理程序
|
|
|
|
BOOL CConfigDLg::OnInitDialog()
|
|
{
|
|
CDialogEx::OnInitDialog();
|
|
|
|
CString strPort;
|
|
strPort.Format("%d", theApp.m_nCameraPort);
|
|
GetDlgItem(IDC_EDIT_PORT)->SetWindowText(strPort);
|
|
|
|
|
|
CString strIp = theApp.m_strCameraIp;
|
|
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]);
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
}
|
|
|
|
|
|
void CConfigDLg::OnBnClickedBtnSetting()
|
|
{
|
|
unsigned char* ip{};
|
|
DWORD dword;
|
|
m_IpAddress.GetAddress(dword);
|
|
ip = (unsigned char*)&dword;
|
|
theApp.m_strCameraIp.Format("%u.%u.%u.%u", *(ip + 3), *(ip + 2), *(ip + 1), *ip);
|
|
|
|
CString strPort;
|
|
GetDlgItem(IDC_EDIT_PORT)->GetWindowText(strPort);
|
|
|
|
|
|
CString iniPath = theApp.m_strModulePath + "\\config.ini";
|
|
WritePrivateProfileString("CAMERA", "IP", theApp.m_strCameraIp, iniPath);
|
|
WritePrivateProfileString("CAMERA", "PORT", strPort, iniPath);
|
|
|
|
theApp.m_nCameraPort = atoi(strPort);
|
|
AfxMessageBox("配置已修改,需要重启插件");
|
|
OnOK();
|
|
}
|