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

📄 mygameview.cpp

📁 一个小游戏五子棋的浙江大学开发我的课程设计
💻 CPP
字号:
// MyGameView.cpp : implementation of the CMyGameView class
//

#include "stdafx.h"
#include "MyGame.h"

#include "MyGameDoc.h"
#include "MyGameView.h"
#include "GameClient.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyGameView

IMPLEMENT_DYNCREATE(CMyGameView, CView)

BEGIN_MESSAGE_MAP(CMyGameView, CView)
	//{{AFX_MSG_MAP(CMyGameView)
	ON_COMMAND(ID_REFRESH, OnRefresh)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyGameView construction/destruction

CMyGameView::CMyGameView()
{
	// TODO: add construction code here
	m_UserNum = 0;

}

CMyGameView::~CMyGameView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMyGameView drawing

void CMyGameView::OnDraw(CDC* pDC)
{
	CMyGameDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CBrush Brush( RGB(238,94,145));
	pDC->SetBkColor(RGB(238,94,145));
	CBrush *pOldBrush = pDC->SelectObject( &Brush);
	CRect rcClip;
	pDC->GetClipBox( &rcClip );
	
	//Paint the area.
	pDC->PatBlt( rcClip.left , rcClip.top, rcClip.Width(), rcClip.Height() , PATCOPY );
	//Unselect brush out of device context .
	pDC->SelectObject(pOldBrush );
	// Return nonzero to half fruther processing .
	//显示用户信息
	for( int num = 0; num < m_UserNum; num++ )
	{
		CString info;
		info.Format("用户:%s  房间号:%d", m_UserInfo[num].GetName().c_str(),
								m_UserInfo[num].GetRoomNum() );
		pDC->TextOut( 5, 5+num*20, info );
	}
	return ;

}

/////////////////////////////////////////////////////////////////////////////
// CMyGameView printing

BOOL CMyGameView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyGameView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyGameView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMyGameView diagnostics

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

void CMyGameView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CMyGameView message handlers

void CMyGameView::OnRefresh() 
{
	// TODO: Add your command handler code here
	CMyGameDoc* pDoc = (CMyGameDoc*)GetDocument();
	//if(!pDoc->m_client.IsMyTurn())
	//	return;
//	if(!pDoc->m_client.IsNetFree())
//		return;
//	pDoc->m_client.GetAllUserInfo();
	m_UserNum = pDoc->m_client.GetUserCount();
	for( int num = 0; num < m_UserNum; num++ )
	{
		m_UserInfo[num] = pDoc->m_client.GetUserInfo(num);
	}
	Invalidate();
	
}
void CMyGameView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	OnRefresh();
}

⌨️ 快捷键说明

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