// gameFrame.cpp : implementation file
//
#include "stdafx.h"
#include "gameFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// gameFrame
IMPLEMENT_DYNCREATE(gameFrame, CFrameWnd)
CPen newPen,*oldPen;
gameFrame::gameFrame()
{
RECT rect;
Create(NULL,"绘图窗口");
CClientDC dc(this);
int width = dc.GetDeviceCaps(HORZRES);
int height = dc.GetDeviceCaps(VERTRES);
GetWindowRect( &rect );
width = ( width - ( rect.right - rect.left ))/2 ;
height = (height - (rect.bottom - rect.top ))/2 ;
MoveWindow( width ,
height ,
(rect.right - rect.left ) ,
(rect.bottom - rect.top ) ,
true );
newPen.CreatePen(PS_DASH,5,RGB(0,0,255));
}
gameFrame::~gameFrame()
{
}
BEGIN_MESSAGE_MAP(gameFrame, CFrameWnd)
//{{AFX_MSG_MAP(gameFrame)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// gameFrame message handlers
void gameFrame::OnPaint()
{
int j=12,ptype,x=100,y=10;
CPaintDC dc(this);
oldPen=dc.SelectObject(&newPen);
dc.MoveTo(x,y);
for(int i=0;i<19;i++)
{
ptype = i % 4;
switch(ptype)
{
case 0:
j-=2;
x = x + 40 * j;
break;
case 1:
y = y + 40 * j;
break;
case 2:
x = x - (j - 1) * 40;
break;
case 3:
y = y - (j -1 ) * 40;
break;
default:
break;
}
dc.LineTo(x,y);
}
dc.SelectObject(oldPen);
}