~cpp 
// omokView.cpp : implementation of the COmokView class
//
#include "stdafx.h"
#include "omok.h"
#include "omokDoc.h"
#include "omokView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COmokView
IMPLEMENT_DYNCREATE(COmokView, CView)
BEGIN_MESSAGE_MAP(COmokView, CView)
	//{{AFX_MSG_MAP(COmokView)
	ON_WM_LBUTTONDOWN()
	//}}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()
/////////////////////////////////////////////////////////////////////////////
// COmokView construction/destruction
COmokView::COmokView()
{
	init();
}
void COmokView::init()
{
	row = -1;
	col = -1;
	number=0;
	for(int row=0;row<19;row++)
		for(int col=0;col<19;col++)
			omokBoard[row][col]=0;
}
COmokView::~COmokView()
{
}
BOOL COmokView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// COmokView drawing
void COmokView::OnDraw(CDC* pDC)
{
	COmokDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CBrush white(RGB(255,255,255));
	CBrush black(RGB(0,0,0,));
	// 오목판  줄 긋기
	for( int i = 20 ; i <= 560 ; i += 30 )
	{
		pDC->MoveTo(i, 20);
		pDC->LineTo(i, 560);
		pDC->MoveTo(20, i);
		pDC->LineTo(560, i);
	}
	// 천원(天元), 화점(花點) 찍기
	pDC->SelectObject(&black);
	pDC->Ellipse(3*30+20-5,3*30+20-5,3*30+20+5,3*30+20+5);
	pDC->Ellipse(9*30+20-5,3*30+20-5,9*30+20+5,3*30+20+5);
	pDC->Ellipse(15*30+20-5,3*30+20-5,15*30+20+5,3*30+20+5);
	pDC->Ellipse(3*30+20-5,9*30+20-5,3*30+20+5,9*30+20+5);
	pDC->Ellipse(9*30+20-5,9*30+20-5,9*30+20+5,9*30+20+5);
	pDC->Ellipse(15*30+20-5,9*30+20-5,15*30+20+5,9*30+20+5);
	pDC->Ellipse(3*30+20-5,15*30+20-5,3*30+20+5,15*30+20+5);
	pDC->Ellipse(9*30+20-5,15*30+20-5,9*30+20+5,15*30+20+5);
	pDC->Ellipse(15*30+20-5,15*30+20-5,15*30+20+5,15*30+20+5);
	// 돌 놓기
	for(int row=0;row<19;row++)
		for(int col=0;col<19;col++)
			if(omokBoard[row][col]!=0)
			{
				if(omokBoard[row][col]%2==1)
					pDC->SelectObject(&black);
				else
					pDC->SelectObject(&white);
				pDC->Ellipse(row*30+10, col*30+10, row*30+30, col*30+30);
			}
}
/////////////////////////////////////////////////////////////////////////////
// COmokView printing
BOOL COmokView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}
void COmokView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}
void COmokView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// COmokView diagnostics
#ifdef _DEBUG
void COmokView::AssertValid() const
{
	CView::AssertValid();
}
void COmokView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
COmokDoc* COmokView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COmokDoc)));
	return (COmokDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COmokView message handlers
void COmokView::OnLButtonDown(UINT nFlags, CPoint point)
{
	row=(point.x-5)/30;
	col=(point.y-5)/30;
	if((row>=0 && row<19) && (col>=0 && col<19) && omokBoard[row][col] == 0)
		omokBoard[row][col] = ++number;
	Invalidate(true);
	if(CheckOmok())
	{
		if(number % 2 == 0)
			MessageBox("흰 돌 승리!!");
		else
			MessageBox("검은돌 승리!!");
		init();
		Invalidate(true);
	}
	CView::OnLButtonDown(nFlags, point);
}
bool COmokView::CheckOmok()
{
	// Left & Right
	count = 0;
	if (row > 0)
		CheckMove(row, col, -1, 0);
	if (row < 19)
		CheckMove(row, col, 1, 0);
	if (count == 4)
		return true;
	// LeftUpper & RightBottom
	count = 0;
	if (row > 0 && col > 0)
		CheckMove(row, col, -1, -1);
	if (row < 19 && col < 19)
		CheckMove(row, col, 1, 1);
	if (count == 4)
		return true;
	// Upper & Bottom
	count = 0;
	if (col > 0)
		CheckMove(row, col, 0, -1);
	if (col < 19)
		CheckMove(row, col, 0, 1);
	if (count == 4)
		return true;
	// RightUpper & LeftBottom
	count = 0;
	if (col > 0 && row < 19)
		CheckMove(row, col, 1, -1);
	if (col < 19 && row > 0)
		CheckMove(row, col, -1, 1);
	if (count == 4)
		return true;
	return false;
}
void COmokView::CheckMove(int r, int c, int x, int y)
{
	r += x;
	c += y;
	if (omokBoard[r][c] != 0)
		if (omokBoard[r][c] % 2 == omokBoard[row][col] % 2)
		{
			count++;
			CheckMove(r,c, x, y);
		}
}