// RemoteCfgDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "NetSDKDemo.h"
#include "RemoteCfgDlg.h"
#include "UCRemoteConfig.h"


// CRemoteCfgDlg 对话框

IMPLEMENT_DYNAMIC(CRemoteCfgDlg, CDialog)

CRemoteCfgDlg::CRemoteCfgDlg(CDevInfo *pDevInfo,CWnd* pParent /*=NULL*/)
	: CDialog(CRemoteCfgDlg::IDD, pParent)
{
	m_lInit = 0;
	m_pDevInfo = pDevInfo;
}

CRemoteCfgDlg::~CRemoteCfgDlg()
{
}

void CRemoteCfgDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CRemoteCfgDlg, CDialog)
	ON_WM_CLOSE()
END_MESSAGE_MAP()


// CRemoteCfgDlg 消息处理程序

BOOL CRemoteCfgDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	

	OnSetCfgDevIP(m_pDevInfo);

	return TRUE;  // return TRUE unless you set the focus to a control	
}

void CRemoteCfgDlg::OnSetCfgDevIP(CDevInfo *pDevInfo)
{
	if (m_lInit <= 0)
	{
		m_lInit = CFG_UC_Init(pDevInfo->m_IPCEntry.lanCfg.IPAddress, pDevInfo->m_IPCEntry.streamCfg.ptzPort, pDevInfo->m_IPCEntry.userCfg.accounts[0].userName, pDevInfo->m_IPCEntry.userCfg.accounts[0].password, "zh-cn", this);//zh-cn;en;
		CRect rcPos;
		this->GetClientRect(rcPos);
		this->ClientToScreen(rcPos);
		CFG_UC_ShowModelessDlg(m_lInit, rcPos);
	}
}
void CRemoteCfgDlg::OnClose()
{
	if (m_lInit > 0)
	{
		CFG_UC_ShowModelessDlg(m_lInit, CRect(0, 0, 0, 0));
		CFG_UC_UnInit(m_lInit);
		m_lInit = 0;
		m_pDevInfo = NULL;
	}

	CDialog::OnClose();
}
