www.gusucode.com > VC++编写的SQL服务端和客户端源码程序 > VC++编写的SQL服务端和客户端源码程序\code\Server\ServerView.cpp

    // ServerView.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "miniSQL.h"
#include "ServerView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CServerView

IMPLEMENT_DYNCREATE(CServerView, CEditView)

CServerView::CServerView()
{
	pFont = new CFont();
}

CServerView::~CServerView()
{
	if( pFont )
	{
		pFont->DeleteObject();
		delete pFont;
	}
}


BEGIN_MESSAGE_MAP(CServerView, CEditView)
	//{{AFX_MSG_MAP(CServerView)
	ON_COMMAND(ID_CHANGE_FONT, OnChangeFont)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CServerView drawing

void CServerView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CServerView diagnostics

#ifdef _DEBUG
void CServerView::AssertValid() const
{
	CEditView::AssertValid();
}

void CServerView::Dump(CDumpContext& dc) const
{
	CEditView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CServerView message handlers

void CServerView::Message(LPCTSTR lpszMessage)
{
	CTime time = CTime::GetCurrentTime();
	CString strTemp = time.Format("%H:%M:%S %p, %m-%d-%Y : "); 

	strTemp += (CString)lpszMessage + "\r\n\r\n";
	int len = GetWindowTextLength();
	GetEditCtrl().SetSel(len,len);
	GetEditCtrl().ReplaceSel(strTemp);
}

void CServerView::OnChangeFont() 
{
	LOGFONT lf;
	ZeroMemory( &lf, sizeof( lf ) );
	CFontDialog fDlg( &lf );

	if( fDlg.DoModal() == IDOK )
	{
		pFont->DeleteObject();
		pFont->CreateFontIndirect( &lf );
		GetEditCtrl().SetFont( pFont );
		Invalidate( FALSE );
	}
}