⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftptestdlg.cpp

📁 运行于Wince平台的FTP客户端
💻 CPP
字号:
// ftpTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ftpTest.h"
#include "ftpTestDlg.h"
#include "ftpsockclient.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFtpTestDlg dialog

CFtpTestDlg::CFtpTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFtpTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFtpTestDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CFtpTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFtpTestDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFtpTestDlg, CDialog)
	//{{AFX_MSG_MAP(CFtpTestDlg)
	ON_BN_CLICKED(IDC_GO, OnGo)
	ON_BN_CLICKED(IDC_DICONNECT, OnDiconnect)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFtpTestDlg message handlers

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

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	RECT	rect;
	GetClientRect( &rect );

	this -> MoveWindow( &rect, TRUE );

	// TODO: Add extra initialization here

	SetDlgItemText( IDC_ADDRESS, _T("ftp.microsoft.com") );

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



void CFtpTestDlg::OnGo() 
{
	CString csAddress;
	GetDlgItemText( IDC_ADDRESS, csAddress );

	if( csAddress.IsEmpty() )
	{
		AfxMessageBox( L"Invalid Address" );
		return;
	}

	SetDlgItemText( IDC_OUTPUT, m_ftp.GetStatusFromServer() );

	BOOL bResult = m_ftp.ConnectToServer( csAddress, 21 );

	if( ! bResult )
	{
		AfxMessageBox( L"Error Connecting to Server" );
		return;
	}

	SetDlgItemText( IDC_OUTPUT, m_ftp.GetStatusFromServer());

	bResult = m_ftp.UserLogin( L"anonymous", L"dummy@ftpdemo.com" );
	if( ! bResult )
	{
		AfxMessageBox( L"Error Connecting to Server" );
		return;
	}

	SetDlgItemText( IDC_OUTPUT, m_ftp.GetStatusFromServer() );


	CString csDir = m_ftp.GetWorkingDirectory();

	CString csFileList;
	m_ftp.GetFileList( csDir, csFileList );

	SetDlgItemText( IDC_OUTPUT, csFileList );

}


void CFtpTestDlg::OnDiconnect() 
{
	m_ftp.DisconnectFromServer();	
	SetDlgItemText ( IDC_OUTPUT, m_ftp.GetStatusFromServer() );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -