📄 childview.cpp
字号:
// ChildView.cpp : implementation of the CChildView class
//
#include "stdafx.h"
#include "Array.h"
#include "ChildView.h"
#include <math.h>
#include <afxtempl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define PI 3.14159
/////////////////////////////////////////////////////////////////////////////
// CChildView
CChildView::CChildView()
{
}
CChildView::~CChildView()
{
}
BEGIN_MESSAGE_MAP(CChildView,CWnd )
//{{AFX_MSG_MAP(CChildView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildView message handlers
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
return TRUE;
}
void CChildView::OnPaint()
{
RECT rcClient;
CPoint ptOrg;
CPoint point;
CArray<CPoint, CPoint&> points;
double fAngle, fRadius;
int i;
CPen pen, *penOld;
CPaintDC dc(this); // device context for painting
pen.CreatePen (PS_SOLID, 2, (COLORREF) 0);
penOld = (CPen *) dc.SelectObject (&pen);
GetClientRect (&rcClient);
fRadius = rcClient.bottom / 3.0;
ptOrg = dc.SetViewportOrg (rcClient.right / 2, rcClient.bottom / 2);
for (i = 0, fAngle = PI/2; i < 5; ++i, fAngle += 6 * PI/5.0)
{
point.x = (long)(fRadius * cos (fAngle) + 0.5);
point.y = (long)(-fRadius * sin (fAngle) + 0.5);
points.Add (CPoint (point.x, point.y));
}
points.Add (CPoint (points[0].x, points[0].y));
dc.MoveTo (points[0].x, points[0].y);
for (i = 1; i < 6; ++i)
dc.LineTo (points[i].x, points[i].y);
dc.SelectObject (penOld);
dc.SetViewportOrg (ptOrg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -