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

📄 serverview.cpp

📁 面向软件工程的Visual C++网络程序开发
💻 CPP
字号:
// ServerView.cpp : implementation of the CServerView class
//

#include "stdafx.h"
#include "Server.h"

#include "ServerDoc.h"
#include "ServerView.h"

#include "ListenSocket.h"

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

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

IMPLEMENT_DYNCREATE(CServerView, CListView)

BEGIN_MESSAGE_MAP(CServerView, CListView)
	//{{AFX_MSG_MAP(CServerView)
//	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CServerView construction/destruction

CServerView::CServerView()
{
	// TODO: add construction code here
}

CServerView::~CServerView()
{
}

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

	return CListView::PreCreateWindow(cs);
}

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

void CServerView::OnDraw(CDC* pDC)
{
	CServerDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

void CServerView::OnInitialUpdate()
{
	CListView::OnInitialUpdate();
	CListCtrl& listCtrl = GetListCtrl();

	::SetWindowLong(listCtrl.GetSafeHwnd(), GWL_STYLE, listCtrl.GetStyle() | LVS_REPORT);
	listCtrl.SetExtendedStyle(LVS_EX_GRIDLINES);

	listCtrl.InsertColumn(1, "时    间", LVCFMT_CENTER, 140);
	listCtrl.InsertColumn(2, "消          息", LVCFMT_CENTER, 600);
}

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

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CServerView message handlers
void CServerView::AppendMessage(CString &message)
{
	CListCtrl& listCtrl = GetListCtrl();
	CTime tmCurrent = CTime::GetCurrentTime();
	CString strCurTime = tmCurrent.Format("%m月%d日%H时%M分%S秒");
	int iItemCnt = listCtrl.GetItemCount();

	listCtrl.InsertItem(iItemCnt, strCurTime);
	listCtrl.SetItemText(iItemCnt, 1, message);
}

⌨️ 快捷键说明

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