www.pudn.com > CraftFTP_gb.rar > ConnectWizard.cpp


// ConnectWizard.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "CraftFTP.h" 
#include "ConnectWizard.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CConnectWizard 
 
IMPLEMENT_DYNAMIC(CConnectWizard, CPropertySheetExt) 
 
CConnectWizard::CConnectWizard(CWnd * pOwner, UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) 
	:CPropertySheetExt(nIDCaption, pParentWnd, iSelectPage) 
{ 
	m_pParent = pParentWnd; 
	CommonConstruct(); 
} 
 
CConnectWizard::CConnectWizard(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) 
	:CPropertySheetExt(pszCaption, pParentWnd, iSelectPage) 
{ 
	m_pParent = pParentWnd; 
	CommonConstruct(); 
} 
 
CConnectWizard::~CConnectWizard() 
{ 
} 
 
BEGIN_MESSAGE_MAP(CConnectWizard, CPropertySheetExt) 
	//{{AFX_MSG_MAP(CConnectWizard) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CConnectWizard message handlers 
 
void CConnectWizard::CommonConstruct() 
{ 
	AddPage(&Page1); 
	AddPage(&Page2); 
	AddPage(&Page3); 
	AddPage(&Page4); 
	AddPage(&Page5); 
	AddPage(&Page6); 
 
	SetWizardMode(); 
} 
 
void CConnectWizard::OnWizardFinish() 
{ 
	CCraftFTPApp * theApp = (CCraftFTPApp*)AfxGetApp(); 
 
	CString szRemotePath = _T("/"); 
	if(Page5.m_szProfilePath.IsEmpty()) 
		Page5.m_szProfilePath =	_T("/"); 
 
	if(Page4.m_bAnonymousLogin || Page4.m_szUserName==_T("anonymous")) 
		Page4.m_szPassWord = _T(""); 
 
	//新增FTP站点 
	CFavoritesManager::CFavoriteProfile * pProfile = new CFavoritesManager::CFavoriteProfile; 
	if(pProfile) 
	{ 
		pProfile->nCommandID		=	theApp->m_Favorites.GetCmdID(); 
		pProfile->szHostLabel		=	Page2.m_szSiteLabel; 
		pProfile->szHostName		=	Page3.m_szHostName; 
		pProfile->szDirectory		=	szRemotePath; 
		pProfile->szProfilePath		=	Page5.m_szProfilePath; 
		pProfile->szUserName		=	Page4.m_szUserName; 
		pProfile->szPassWord		=	Page4.m_szPassWord; 
		pProfile->nPort				=	Page4.m_nPort; 
		pProfile->szSiteComment		=	_T(""); 
		theApp->m_Favorites.AddProfile(pProfile); 
 
		//立即连接 
		if(Page6.m_bConnectNow) 
		{ 
			//关闭对话框 
			if(m_pParent) 
				m_pParent->SendMessage(WM_COMMAND, IDOK); 
 
			//连接站点 
			theApp->m_pMainWnd->PostMessage(WM_COMMAND, pProfile->nCommandID); 
		} 
	} 
}