#include <afxwin.h>
#include "draw.h"
CMyApp myApp;
BOOL CMyApp::InitInstance() {
m_pMainWnd = new CMainWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd)
ON_WM_SIZE()
ON_WM_PAINT()
END_MESSAGE_MAP()
CMainWindow::CMainWindow() {
Create(NULL, "画画图");
}
void CMainWindow::OnSize(UINT uType,
int cx,
int cy) {
cxClient = cx;
cyClient = cy;
}
void CMainWindow::OnPaint() {
CPaintDC dc(this);
dc.MoveTo(0, cyClient / 2);
dc.LineTo(cxClient, cyClient / 2);
dc.MoveTo(cxClient / 2, 0);
dc.LineTo(cxClient / 2, cyClient);
pt[0].x = cxClient / 4;
pt[0].y = 0;
pt[1].x = cxClient / 2;
pt[1].y = cyClient / 4;
pt[2].x = cxClient / 4;
pt[2].y = cyClient / 2;
pt[3].x = 0;
pt[3].y = cyClient / 4;
dc.Polygon(pt, 4);
dc.Ellipse(cxClient / 2, 0, cxClient, cyClient / 2);
dc.RoundRect(cxClient / 8, 5 * cyClient / 8,
cxClient / 2 - cxClient / 8, cyClient - cyClient / 8,
cxClient / 16, cyClient / 16);
dc.Chord(cxClient / 2, cyClient / 2, 3 * cxClient / 2, 3* cyClient / 2,
cxClient, cyClient / 2, cxClient / 2, cyClient);
}
|