www.pudn.com > GGBT.rar > DlgDownloadSetup.cpp


// DlgDownloadSetup.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "testbt.h" 
#include "DlgDownloadSetup.h" 
 
#include "FileBase.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDlgDownloadSetup dialog 
 
 
CDlgDownloadSetup::CDlgDownloadSetup(CWnd* pParent /*=NULL*/) 
	: CPropertyPage(CDlgDownloadSetup::IDD) 
{ 
	//{{AFX_DATA_INIT(CDlgDownloadSetup) 
	//}}AFX_DATA_INIT 
	// m_bCompleteKeepSeed = FALSE; 
	 
	m_lConnectErrorMax = 200; 
	m_lConnectIntval = 10; 
	m_lDownloadAllCount = 10; 
} 
 
 
void CDlgDownloadSetup::DoDataExchange(CDataExchange* pDX) 
{ 
	CPropertyPage::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CDlgDownloadSetup) 
	DDX_Control(pDX, IDC_STATIC_UP_SPEED_INFO, m_stUpSpeedInfo); 
	DDX_Control(pDX, IDC_GROUP_UPLOAD_SPEED, m_gpUpSpeed); 
	DDX_Control(pDX, IDC_GROUP_CON_SETUP, m_gpConSetup); 
	DDX_Control(pDX, IDC_SPIN_COMPLETE_KEEP_SEED_HOUR, m_spinCompleteKeepSeedHour); 
	DDX_Control(pDX, IDC_SPIN_DOWNLOAD_ALL_COUNT, m_spinDownloadAllCount); 
	DDX_Control(pDX, IDC_SPIN_CONNECT_INTVAL, m_spinConnectIntval); 
	DDX_Control(pDX, IDC_SPIN_CONNECT_ERR_MAX, m_spinConnectErrMax); 
	DDX_Control(pDX, IDC_COMBO_DOWN_SPEED, m_cbDownSpeed); 
	DDX_Control(pDX, IDC_SPIN_PORT_MAX, m_spinPortMax); 
	DDX_Control(pDX, IDC_SPIN_PORT_MIN, m_spinPortMin); 
	//}}AFX_DATA_MAP 
	// DDX_Check(pDX, IDC_CHECK_KEEP_SEED, m_bCompleteKeepSeed); 
} 
 
 
BEGIN_MESSAGE_MAP(CDlgDownloadSetup, CPropertyPage) 
	//{{AFX_MSG_MAP(CDlgDownloadSetup) 
	ON_CBN_SELCHANGE(IDC_COMBO_DOWN_SPEED, OnSelchangeComboDownSpeed) 
	//}}AFX_MSG_MAP 
	// ON_BN_CLICKED(IDC_CHECK_KEEP_SEED, OnCheckKeepSeed) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDlgDownloadSetup message handlers 
BOOL CDlgDownloadSetup::OnInitDialog()  
{ 
	CPropertyPage::OnInitDialog(); 
 
	// 
	// Up speed setup. 
	// 
	m_spinPortMin.SetBuddy(GetDlgItem(IDC_EDIT_PORT_MIN)); 
	m_spinPortMax.SetBuddy(GetDlgItem(IDC_EDIT_PORT_MAX)); 
 
	m_spinPortMin.SetRange(1, 31000); 
	m_spinPortMax.SetRange(1, 32000); 
 
	m_spinConnectIntval.SetBuddy(GetDlgItem(IDC_EDIT_CONNECT_INTVAL)); 
	m_spinConnectErrMax.SetBuddy(GetDlgItem(IDC_EDIT_CONNECT_ERR_MAX)); 
	m_spinDownloadAllCount.SetBuddy(GetDlgItem(IDC_EDIT_DOWNLOAD_ALL_COUNT)); 
	m_spinConnectIntval.SetRange(0, 500); 
	m_spinConnectErrMax.SetRange(1, 10000); 
	m_spinDownloadAllCount.SetRange(1, 1000); 
 
	m_spinCompleteKeepSeedHour.SetBuddy(GetDlgItem(IDC_EDIT_COMPLETE_KEEP_SEED_HOUR)); 
	m_spinCompleteKeepSeedHour.SetRange(0, 1000); 
	 
	for (int i=0; im_lDownSpeed; 
	m_lPortMin = pSetupRegister->m_lPortMin; 
	m_lPortMax = pSetupRegister->m_lPortMax; 
	m_lConnectErrorMax = pSetupRegister->m_lConnectErrorMax; 
	m_lConnectIntval = pSetupRegister->m_lConnectIntval; 
	m_lDownloadAllCount = pSetupRegister->m_lDownloadAllCount;	 
	// m_bCompleteKeepSeed = pSetupRegister->m_bCompleteKeepSeed; 
	m_lCompleteKeepSeedHour = pSetupRegister->m_lCompleteKeepSeedHour; 
 
	m_spinPortMin.SetPos(m_lPortMin); 
	m_spinPortMax.SetPos(m_lPortMax); 
	m_spinConnectErrMax.SetPos(m_lConnectErrorMax); 
	m_spinConnectIntval.SetPos(m_lConnectIntval); 
	m_spinDownloadAllCount.SetPos(m_lDownloadAllCount); 
	m_spinCompleteKeepSeedHour.SetPos(m_lCompleteKeepSeedHour); 
	 
	m_cbDownSpeed.SetCurSel(0); 
	for (int i=0; m_cbDownSpeed.GetCount(); i++) 
	{ 
		if (m_cbDownSpeed.GetItemData(i) == m_lDownSpeed) 
		{ 
			m_cbDownSpeed.SetCurSel(i); 
			break; 
		} 
	} 
 
	UpdateData(false); 
 
	OnCheckKeepSeed(); 
	OnSelchangeComboDownSpeed(); 
} 
 
void CDlgDownloadSetup::GetData(CSetupRegister *pSetupRegister) 
{ 
	pSetupRegister->m_lDownSpeed = m_lDownSpeed; 
	pSetupRegister->m_lPortMin = m_lPortMin ; 
	pSetupRegister->m_lPortMax = m_lPortMax; 
	pSetupRegister->m_lConnectErrorMax = m_lConnectErrorMax; 
	pSetupRegister->m_lConnectIntval = m_lConnectIntval; 
	pSetupRegister->m_lDownloadAllCount = m_lDownloadAllCount; 
	pSetupRegister->m_lCompleteKeepSeedHour = m_lCompleteKeepSeedHour; 
	// pSetupRegister->m_bCompleteKeepSeed = m_bCompleteKeepSeed != 0; 
} 
 
 
void CDlgDownloadSetup::OnOK()  
{ 
	GetParent()->SendMessage(WM_COMMAND, IDOK, 0); 
	CPropertyPage::OnOK(); 
} 
 
void CDlgDownloadSetup::OnCancel()  
{ 
	GetParent()->SendMessage(WM_COMMAND, IDCANCEL, 0); 
	CPropertyPage::OnCancel(); 
} 
 
void CDlgDownloadSetup::OnCheckKeepSeed()  
{ 
	UpdateData(); 
	// m_spinCompleteKeepSeedHour.EnableWindow(m_bCompleteKeepSeed); 
	// GetDlgItem(IDC_EDIT_COMPLETE_KEEP_SEED_HOUR)->EnableWindow(m_bCompleteKeepSeed); 
} 
 
 
void CDlgDownloadSetup::OnSelchangeComboDownSpeed()  
{ 
	long lCurSel = m_cbDownSpeed.GetCurSel(); 
	if (lCurSel < 0 || lCurSel >= CSpeedParameters::eSpeedModeAll) 
	{ 
		ASSERT(FALSE); 
		return; 
	} 
 
	CString strText; 
	strText.Format("最大上传速度(0代表无限速): %dKB, 最大上传连接:%d", CSpeedParameters::m_lArrSpeedVal[lCurSel], CSpeedParameters::m_lArrPeerVal[lCurSel]); 
	m_stUpSpeedInfo.SetWindowText(strText); 
}