www.pudn.com > 17123337.rar > SetupDlg.cpp


// SetupDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "TCPClient.h" 
#include "SetupDlg.h" 
#include "TCPClientDoc.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CSetupDlg dialog 
 
 
CSetupDlg::CSetupDlg(CTCPClientDoc *pDoc, CWnd* pParent /*=NULL*/) 
	: CDialog(CSetupDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CSetupDlg) 
	m_pDoc = pDoc; 
	m_Port = m_pDoc->iServerPort; 
	m_strKey = m_pDoc->strKey; 
	//}}AFX_DATA_INIT 
} 
 
 
void CSetupDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSetupDlg) 
	DDX_Control(pDX, IDC_IPADDRESS, m_IPAddrCtrl); 
	DDX_Text(pDX, IDC_EDITPORT, m_Port); 
	DDX_Text(pDX, IDC_EDITKEY, m_strKey); 
	DDV_MaxChars(pDX, m_strKey, 16); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CSetupDlg, CDialog) 
	//{{AFX_MSG_MAP(CSetupDlg) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSetupDlg message handlers 
 
BOOL CSetupDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	m_IPAddrCtrl.SetAddress(m_pDoc->dwServerIP); 
	// TODO: Add extra initialization here 
//	m_IPAddrCtrl.SetDlgItemInt 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CSetupDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
	UpdateData(TRUE); 
	if (m_strKey.GetLength()!=16 && m_strKey.GetLength()!=0) 
	{ 
		MessageBox("DES密钥必须是16位长", "提示信息",MB_OK|MB_ICONERROR); 
		return; 
	} 
	m_pDoc->iServerPort = m_Port; 
	m_IPAddrCtrl.GetAddress(m_pDoc->dwServerIP); 
	m_pDoc->strKey = m_strKey; 
	CDialog::OnOK(); 
}