tableview.cpp

来自「Visual C++网络游戏设计与实现(附书源码)」· C++ 代码 · 共 123 行

CPP
123
字号
// tableview.cpp : implementation file
//

#include "stdafx.h"
#include "..\gamehigh.h"
#include "..\include\tableview.h"
#include "macros.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTableView

IMPLEMENT_DYNCREATE(CTableView, CView)

CTableView::CTableView()
{
	pTablePage	=NULL;
}

CTableView::~CTableView()
{
	SAFE_CHECKPOINTER(pTablePage)
	{
		SAFE_CHECKWND(pTablePage)
		{
			pTablePage->DestroyWindow();
		}
		pTablePage	=NULL;
	}
}


BEGIN_MESSAGE_MAP(CTableView, CView)
	//{{AFX_MSG_MAP(CTableView)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

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

/////////////////////////////////////////////////////////////////////////////
// CTableView diagnostics

#ifdef _DEBUG
void CTableView::AssertValid() const
{
	CView::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CTableView message handlers

int CTableView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	if(NULL == pTablePage)
	{
		pTablePage	=new CTablePage();
		RECT	rect;
		memset(&rect, 0, sizeof(RECT));
		pTablePage->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, 
			rect, this, 0, NULL);
	}
	
	m_wndDlg.Create(this);
	return 0;
}

void CTableView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	SAFE_CHECKWND(pTablePage)
	{
		RECT	rect;
		memset(&rect, 0, sizeof(RECT));
		this->GetClientRect(&rect);
		rect.bottom	-=30;
		pTablePage->MoveWindow(&rect);
	}

	CWnd*	pWnd	=&m_wndDlg;
	SAFE_CHECKWND(pWnd)
	{
		RECT	rect;
		memset(&rect, 0, sizeof(RECT));
		this->GetClientRect(&rect);
		rect.top	=rect.bottom - 30;
		pWnd->MoveWindow(&rect);
	}
}

CTablePage* CTableView::GetTablePage()
{
	return pTablePage;
}

BOOL CTableView::OnEraseBkgnd(CDC* pDC) 
{
	return TRUE;	
}

⌨️ 快捷键说明

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