Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Complete FTP Server

, 30 May 2005
This article presents a fully functional implementation of a FTP server.
/****************************************************************/
/*																*/
/*  TracePage.cpp												*/
/*																*/
/*  Implementation of the CTracePage class.						*/
/*	This class is a part of Quick 'n Easy FTP Server.			*/
/*																*/
/*  Programmed by Pablo van der Meer							*/
/*  Copyright Pablo Software Solutions 2005						*/
/*	http://www.pablosoftwaresolutions.com						*/
/*																*/
/*  Last updated: May 28, 2005									*/
/*																*/
/****************************************************************/


#include "stdafx.h"
#include "FTPServerApp.h"
#include "TracePage.h"

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


IMPLEMENT_DYNCREATE(CTracePage, CDialog)

CTracePage::CTracePage() : CDialog(CTracePage::IDD)
{
	//{{AFX_DATA_INIT(CTracePage)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CTracePage::~CTracePage()
{
	while(!m_LogQueue.IsEmpty())
	{
		CLogMsg *pLogMsg = (CLogMsg *)m_LogQueue.RemoveHead();
		delete pLogMsg;
	}
}

void CTracePage::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTracePage)
	DDX_Control(pDX, IDC_TRACE, m_TraceList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTracePage, CDialog)
	//{{AFX_MSG_MAP(CTracePage)
	ON_WM_SIZE()
	ON_COMMAND(ID_TRACE_CLEAR, OnTraceClear)
	ON_WM_CONTEXTMENU()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_ADDTRACELINE, OnAddTraceLine)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTracePage message handlers

void CTracePage::AddTraceLine(LPCTSTR pstrFormat, ...)
{
	CString str;

	// format and write the data we were given
	va_list args;
	va_start(args, pstrFormat);
	str.FormatV(pstrFormat, args);

	try
	{
		// create new message
		CLogMsg *pLogMsg = new CLogMsg;

		GetLocalTime(&pLogMsg->m_sysTime);
		pLogMsg->m_strText = str;

		m_QueueLock.Lock();
		m_LogQueue.AddTail(pLogMsg);
		m_QueueLock.Unlock();
				
		// schedule log action
		PostMessage(WM_ADDTRACELINE);
	}
	catch(...)
	{
	
	}
}


LRESULT CTracePage::OnAddTraceLine(WPARAM, LPARAM)
{
	try
	{
		// get first message in the queue
		CLogMsg *pLogMsg = (CLogMsg *)m_LogQueue.RemoveHead();
		m_TraceList.AddString(pLogMsg->m_strText);
		delete pLogMsg;
	}
	catch(...)
	{
		// something is wrong...
	}
	return TRUE;
}

void CTracePage::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	if (IsWindow(::GetDlgItem(m_hWnd, IDC_TRACE)))
	{
		CRect rect;
		GetClientRect(rect);
//		rect.DeflateRect(5,5,10,10);
		m_TraceList.MoveWindow(rect);
	}
}

void CTracePage::OnTraceClear() 
{
	m_TraceList.ResetContent();	
}

void CTracePage::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	CMenu menu;
	menu.LoadMenu(MAKEINTRESOURCE(IDR_TRACE_MENU));
	menu.GetSubMenu(0)->TrackPopupMenu(0, point.x, point.y, this, NULL);		
}

void CTracePage::OnCancel() 
{
//	CDialog::OnCancel();
}

void CTracePage::OnOK() 
{
//	CDialog::OnOK();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Pablo van der Meer
Web Developer
Netherlands Netherlands
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 30 May 2005
Article Copyright 2002 by Pablo van der Meer
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid