1. 首页
  2. 课程学习
  3. C++/C
  4. 黑白棋mfc简单版

黑白棋mfc简单版

上传者: 2018-12-29 18:44:41上传 ZIP文件 4.61MB 热度 31次
#include "stdafx.h" #include "Draw.h" #include #include #include "DrawDoc.h" #include "DrawView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //zhan// //////////////////////////////////////////////////////////////////////////// // CDrawView IMPLEMENT_DYNCREATE(CDrawView, CView) BEGIN_MESSAGE_MAP(CDrawView, CView) //{{AFX_MSG_MAP(CDrawView) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() //}}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() ///////////////////////////////////////////////////////////////////////////// // CDrawView construction/destruction CDrawView::CDrawView() { // TODO: add construction code here } CDrawView::~CDrawView() { } BOOL CDrawView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CDrawView drawing int board[8][8]; CBrush white(RGB(255,255,255)); CBrush black(RGB(0,0,0)); int player = 1; struct node{ int data[8][8]; struct node*next; }; struct node *head; void CDrawView::OnDraw(CDC* pDC) { int i,j; CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here pDC->Rectangle(CRect(490,0,550,20)); pDC->DrawText("悔棋",CRect(500,5,600,20),0); if(player==1) { pDC->DrawText("白棋",CRect(0,0,100,20),0); } else { pDC->DrawText("黑棋",CRect(0,0,100,20),0); } for(i=0;iMoveTo(50,50+50*i); 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() ///////////////////////////////////////////////////////////////////////////// // CDrawView construction/destruction CDrawView::CDrawView() { // TODO: add construction code here } CDrawView::~CDrawView() { } BOOL CDrawView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CDrawView drawing int board[8][8]; CBrush white(RGB(255,255,255)); CBrush black(RGB(0,0,0)); int player = 1; struct node{ int data[8][8]; struct node*next; }; struct node *head; void CDrawView::OnDraw(CDC* pDC) { int i,j; CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here pDC->Rectangle(CRect(490,0,550,20)); pDC->DrawText("悔棋",CRect(500,5,600,20),0); if(player==1) { pDC->DrawText("白棋",CRect(0,0,100,20),0); } else { pDC->DrawText("黑棋",CRect(0,0,100,20),0); } for(i=0;iMoveTo(50,50+50*i);
用户评论