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

📄 ftpview.cpp

📁 Transfer Files to and from an FTP Server
💻 CPP
字号:
// FTPView.cpp : implementation of the CFTPView class
//

#include "stdafx.h"
#include "FTP.h"

#include "FTPDoc.h"
#include "FTPView.h"
#include "FtpTransfer.h"


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

CListCtrl *ListCtrl;
char *Days[] = {"Sun", "Mon", "Tue", "Wed",
	"Thu", "Fri", "Sat"};
char *Months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
extern CFtpConnection* m_pFtpConnection;
extern CInternetSession* m_pInetSession;
UINT ShowFtpTransferWindow(LPVOID lResult);
CFtpTransfer CFtpWindow;

/////////////////////////////////////////////////////////////////////////////
// CFTPView

IMPLEMENT_DYNCREATE(CFTPView, CListView)

BEGIN_MESSAGE_MAP(CFTPView, CListView)
	//{{AFX_MSG_MAP(CFTPView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFTPView construction/destruction

CFTPView::CFTPView()
{
	// TODO: add construction code here

}

CFTPView::~CFTPView()
{
}

BOOL CFTPView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	cs.style |= LVS_REPORT | LVS_SHOWSELALWAYS;
	return CListView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CFTPView drawing

void CFTPView::OnDraw(CDC* pDC)
{
	CFTPDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CListCtrl& refCtrl = GetListCtrl();
	refCtrl.InsertItem(0, "Item!");
	// TODO: add draw code for native data here
}

void CFTPView::OnInitialUpdate()
{
	CListView::OnInitialUpdate();
	CListCtrl &Lc = GetListCtrl();
	ListCtrl = &Lc;
	Lc.InsertColumn(0, "File Name", LVCFMT_LEFT, 150, 0);
	Lc.InsertColumn(1, "Size", LVCFMT_RIGHT, 75, 1);
	Lc.InsertColumn(2, "Attributes", LVCFMT_LEFT, 75, 2);
	Lc.InsertColumn(3, "Type", LVCFMT_LEFT, 200, 3);
	Lc.InsertColumn(4, "Time", LVCFMT_LEFT, 100, 4);
	CString str;
	if (!str.LoadString(AFX_IDS_APP_TITLE))
		str = _T("AppUnknown");
	m_pInetSession = new CInternetSession(str, 1, PRE_CONFIG_INTERNET_ACCESS);

	// Alert the user if the internet session could
	// not be started and close app
	if (!m_pInetSession)
	{
		AfxMessageBox("Internet session could not be started");
	}
//	hInst = AfxGetApp()->m_hInstance;
	CFtpWindow.Create(IDD_FTPTRANSFER);
//	CFtpWindow.SendMessage(WM_COMMAND, IDC_ADDFILE, 0);
//	AfxBeginThread(ShowFtpTransferWindow, 0);
	// TODO: You may populate your ListView with items by directly accessing
	//  its list control through a call to GetListCtrl().
}

/////////////////////////////////////////////////////////////////////////////
// CFTPView printing

BOOL CFTPView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CFTPView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CFTPView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CFTPView diagnostics

#ifdef _DEBUG
void CFTPView::AssertValid() const
{
	CListView::AssertValid();
}

void CFTPView::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}

CFTPDoc* CFTPView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFTPDoc)));
	return (CFTPDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CFTPView message handlers
void CFTPView::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
{
	//TODO: add code to react to the user changing the view style of your window
}

UINT ShowFtpTransferWindow(LPVOID lResult)
{
//	CFtpTransfer Cftp;
//	Cftp.Create(;
	AfxEndThread(0);
	return 0;
}

⌨️ 快捷键说明

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