⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netctlnetaddrdlg.cpp

📁 TM8000硬盘录像机客户端编程文档和Demo源代码
💻 CPP
字号:
// NetCtlNetAddrDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Sample.h"
#include "NetCtlNetAddrDlg.h"
#include "NetRemoteCtrlDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern CNetRemoteCtrlDlg   *pNetRemoteCtlDlg;
extern USER_DVR_PARAMETER     *Con_pDVRPara; 
extern LoginParam             m_LoginParam;
NetAttrParam     m_NetAttrParam;
extern int ENGLISH;
//-----------------------------------
/////////////////////////////////////////////////////////////////////////////
// CNetCtlNetAddrDlg dialog


CNetCtlNetAddrDlg::CNetCtlNetAddrDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CNetCtlNetAddrDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNetCtlNetAddrDlg)
	m_EditNetName = _T("");
	//}}AFX_DATA_INIT
	pParent = NULL ;
}


void CNetCtlNetAddrDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNetCtlNetAddrDlg)
	DDX_Control(pDX, IDC_RNET_MASK, m_Mask);
	DDX_Control(pDX, IDC_RNET_GATEWAY, m_GateWay);
	DDX_Control(pDX, IDC_RNET_IPADDRESS, m_IPAddress);
	DDX_Text(pDX, IDC_EDITNETNAME, m_EditNetName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CNetCtlNetAddrDlg, CDialog)
	//{{AFX_MSG_MAP(CNetCtlNetAddrDlg)
	ON_BN_CLICKED(IDC_SET_BUTTON, OnSetButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNetCtlNetAddrDlg message handlers


BOOL CNetCtlNetAddrDlg::OnInitDialog() 
{
	char * l_Set;//=_T("Setup");
	char * l_Gateway;//=_T("Gateway:");
	char * l_Subnet;//=_T("Subnet:");
	char * l_IPAddr;//=_T("IP Addr:");
	char * l_NetSet;//=_T("Net setup");
	char * l_NetName;//=_T("Net name:");
	if(ENGLISH)
	{
		l_Set=_T("Setup");
		l_Gateway=_T("Gateway:");
		l_Subnet=_T("Subnet:");
		l_IPAddr=_T("IP Addr:");
		l_NetSet=_T("Net setup");
		l_NetName=_T("Net name:");
	}
	else
	{
		l_Set=_T("设置");
		l_Gateway=_T("网关:");
		l_Subnet=_T("子网掩码:");
		l_IPAddr=_T("IP地址:");
		l_NetSet=_T("网络设置");
		l_NetName=_T("网络名称:");
	}
//#endif

	CDialog::OnInitDialog();
	m_IPAddress.SetAddress(0x00) ;
	m_GateWay.SetAddress(0x00) ;
	m_Mask.SetAddress(0xffffff00) ;

	CWnd           *pWnd ;
	pWnd = GetDlgItem(IDC_SET_BUTTON) ;
	pWnd->SetWindowText(l_Set);
	pWnd = GetDlgItem(IDC_STATICNETSET) ;
	pWnd->SetWindowText(l_NetSet);

	pWnd=GetDlgItem(IDC_STATICGATEWAY);
	pWnd->SetWindowText(l_Gateway);

	pWnd=GetDlgItem(IDC_STATICSUBNET);
	pWnd->SetWindowText(l_Subnet);

	pWnd=GetDlgItem(IDC_STATICIPADDRESS);
	pWnd->SetWindowText(l_IPAddr);

	pWnd=GetDlgItem(IDC_STATICNAME);
	pWnd->SetWindowText(l_NetName);

	((CEdit *)GetDlgItem(IDC_EDITNETNAME))->SetLimitText(30);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CNetCtlNetAddrDlg::OnOK() 
{	

	CDialog::OnOK();
}

void CNetCtlNetAddrDlg::OnSetButton() 
{
	DWORD    ipaddr, gateway, mask ;
	char	 Buf[40];

	UpdateData(TRUE) ;
	m_IPAddress.GetAddress(ipaddr) ;
	m_GateWay.GetAddress(gateway) ;
	m_Mask.GetAddress(mask) ;

    if (pNetRemoteCtlDlg->m_nDVRType <= 0) 
	{
		if(Con_pDVRPara->nNetIPAddr!=ipaddr
			||Con_pDVRPara->nNetGateWay!=gateway
			||Con_pDVRPara->nSubNetMask!=mask)
		{
			Con_pDVRPara->nNetIPAddr=ipaddr;
			Con_pDVRPara->nNetGateWay=gateway;
			Con_pDVRPara->nSubNetMask=mask;
			pNetRemoteCtlDlg->SetNetRemoteAddress(ipaddr, gateway, mask) ;
		}
        
        short len=m_EditNetName.GetLength();
		if(len>MAXNAMELEN)
			len=MAXNAMELEN;
        memset(Con_pDVRPara->DVRName,0,MAXNAMELEN); 
		memcpy(Con_pDVRPara->DVRName,m_EditNetName.GetBuffer(len),len); 
	}
	else
	{
		if(m_NetAttrParam.IPAddress!=ipaddr
			||m_NetAttrParam.NetGateWay!=gateway
			||m_NetAttrParam.SubNetMask!=mask)
		{
			pNetRemoteCtlDlg->SetNetRemoteAddress(ipaddr, gateway, mask) ;
		}
	    memset(Buf,0,40);
		strcpy(Buf,m_EditNetName);
	}
    pNetRemoteCtlDlg->SetNetRemoteName(m_EditNetName);
}

void CNetCtlNetAddrDlg::FreshData(BOOL fresh) 
{
	// TODO: Add your control notification handler code here
	UpdateData(fresh);
}

BOOL CNetCtlNetAddrDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	DWORD t1=0;
	DWORD t2=0;

    t1=pMsg->message;
	t2=(DWORD)pMsg->wParam;
	if(t1==WM_KEYDOWN&&(t2==VK_RETURN||t2==VK_ESCAPE))
       return true;
	
	return CDialog::PreTranslateMessage(pMsg);
}

void CNetCtlNetAddrDlg::Refresh()
{
	char Buf[40];
	if (pNetRemoteCtlDlg->m_nDVRType <= 0) 
	{
		m_IPAddress.SetAddress(Con_pDVRPara->nNetIPAddr);
		m_GateWay.SetAddress(Con_pDVRPara->nNetGateWay);
		m_Mask.SetAddress(Con_pDVRPara->nSubNetMask);
		memset(Buf,0,40);
		memcpy(Buf,Con_pDVRPara->DVRName,31);
		//sprintf(Buf,"%s",Con_pDVRPara->DVRName);//add by lch
//		memcpy(Buf,m_NetAttrParam.DVRName,31);
		m_EditNetName=Buf;
		UpdateData(FALSE);
	}
	else
	{
	    pNetRemoteCtlDlg->GetDvrParam(0,0,PARA_TYPE_NET,&m_NetAttrParam,sizeof(NetAttrParam));	
		m_IPAddress.SetAddress(m_NetAttrParam.IPAddress);
		m_GateWay.SetAddress(m_NetAttrParam.NetGateWay);
		m_Mask.SetAddress(m_NetAttrParam.SubNetMask);
		memset(Buf,0,40);
		memcpy(Buf,m_NetAttrParam.DVRName,31);
//		sprintf(Buf,"%s",m_NetAttrParam.DVRName);//add by lch
		m_EditNetName=Buf;
		UpdateData(FALSE);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -