www.pudn.com > gps-time.rar > FirstRun.cpp


// FirstRun.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "RegionComm.h" 
#include "FirstRun.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CFirstRun dialog 
 
 
CFirstRun::CFirstRun(CWnd* pParent /*=NULL*/) 
	: CDialog(CFirstRun::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CFirstRun) 
	m_iPortNo = 5000; 
	m_sServerName = _T(""); 
	m_iRegionNo = 1; 
	//}}AFX_DATA_INIT 
} 
 
 
void CFirstRun::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CFirstRun) 
	DDX_Control(pDX, IDC_IPADDRESS1, m_IP_C); 
	DDX_Text(pDX, IDC_PORTNO, m_iPortNo); 
	DDV_MinMaxUInt(pDX, m_iPortNo, 1024, 9999); 
	DDX_Text(pDX, IDC_SERVERNAME, m_sServerName); 
	DDV_MaxChars(pDX, m_sServerName, 50); 
	DDX_Text(pDX, IDC_REGINNO, m_iRegionNo); 
	DDV_MinMaxInt(pDX, m_iRegionNo, 1, 254); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CFirstRun, CDialog) 
	//{{AFX_MSG_MAP(CFirstRun) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CFirstRun message handlers 
 
 
void CFirstRun::OnButton1() //确定按钮 
{ 
 
	int ret = m_IP_C.GetAddress(m_iIP); 
 
	unsigned char *p1,*p2; 
	long lIpAddr2; 
 
	if(ret<4) 
		m_iIP = 0; 
	UpdateData(true); 
	m_sServerName.TrimLeft(); 
	m_sServerName.TrimRight(); 
	struct in_addr sAddr; 
	if(m_iIP) 
	{	   
	  p1=(unsigned char*)(&m_iIP); 
	  p2=(unsigned char*)(&lIpAddr2); 
	  for(char i=0;i<4;i++) 
		p2[i]=p1[3-i];  
	  sAddr.S_un.S_addr=lIpAddr2; 
	  m_sIPAddr=inet_ntoa(sAddr); 
	} 
	else 
		m_sIPAddr=""; 
	if(m_iIP == 0 && m_sServerName =="") 
	{ 
		::MessageBox(NULL,_T("请输入中心服务器名或IP地址"),_T("错误"),MB_OK); 
		return; 
	} 
	if(m_iPortNo == 0 ) 
	{ 
		::MessageBox(NULL,_T("请输入中心服务器端口号"),_T("错误"),MB_OK); 
		return; 
	}	 
	OnOK(); 
} 
 
void CFirstRun::OnButton2() //取消按钮  
{ 
	// TODO: Add your control notification handler code here 
	CDialog::OnCancel();  
}