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

📄 debugvw.cpp

📁 讲mfc的书
💻 CPP
字号:
// debugvw.cpp : implementation file
//

#include "stdafx.h"
#include "checker.h"
#include "debugvw.h"
#include "checkdoc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// DebugView

IMPLEMENT_DYNCREATE(DebugView, CScrollView)

DebugView::DebugView()
{
}

DebugView::~DebugView()
{
}


BEGIN_MESSAGE_MAP(DebugView, CScrollView)
	//{{AFX_MSG_MAP(DebugView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// DebugView drawing

void DebugView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CDC *dc=GetDC();  // find text dimensions
	TEXTMETRIC tm;
	dc->GetTextMetrics(&tm);

	CSize sizeTotal;
	sizeTotal.cx = ::GetSystemMetrics(SM_CXSCREEN);
	m_linehi=(tm.tmHeight+tm.tmExternalLeading);
	sizeTotal.cy = 64*m_linehi;
	SetScrollSizes(MM_TEXT, sizeTotal);
}

void DebugView::OnDraw(CDC* pDC)
{
	CCheckerDoc* pDoc = (CCheckerDoc *)GetDocument();
	ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CCheckerDoc)));
	STATE s;
	
	for (int y=0;y<8;y++)
	  for (int x=0;x<8;x++)
	     {
		 CString str;
		 str.Format("(%d,%d)=",x,y);
	     s=pDoc->CellState(x,y);
		 switch (s)
		   {
		   case CELL_EMPTY:
		      str+="Empty";
			  break;
		   case CELL_RED:
		   	  str+="Red";
			  break;
		   case CELL_BLACK:
		      str+="Black";
			  break;
		   case CELL_REDKING:
		      str+="Red King";
			  break;
		   case CELL_BLACKKING:
		      str+="Black King";
			  break;
		   default:
		   	  str+="Unknown";
			  break;
			} 
		 pDC->SetBkMode(TRANSPARENT);
		 pDC->TextOut(0,m_linehi*(y*8+x),str);
		 }
}

/////////////////////////////////////////////////////////////////////////////
// DebugView diagnostics

#ifdef _DEBUG
void DebugView::AssertValid() const
{
	CScrollView::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// DebugView message handlers

⌨️ 快捷键说明

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