绘图基础--椭圆

发布时间:2016-12-11 8:21:12 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"绘图基础--椭圆",主要涉及到绘图基础--椭圆方面的内容,对于绘图基础--椭圆感兴趣的同学可以参考一下。

绘图基础--椭圆 // ellipse.cpp #include <afxwin.h> // Define the application class class CApp : public CWinApp { public: virtual BOOL InitInstance(); }; CApp App; // define the window class class CWindow : public CFrameWnd { public: CWindow(); void OnPaint(); DECLARE_MESSAGE_MAP() }; // The window's constructor CWindow::CWindow() { Create(NULL, "Drawing Tests",WS_OVERLAPPEDWINDOW,CRect(0,0,500,400)); } // The message map BEGIN_MESSAGE_MAP( CWindow, CFrameWnd ) ON_WM_PAINT() END_MESSAGE_MAP() // Handle exposures void CWindow::OnPaint() { CRect rect; GetClientRect( rect ); CPaintDC dc(this); // Create a new pen CPen pen(PS_SOLID, 2, RGB(0,0,255)), *oldPen; oldPen = dc.SelectObject(&pen); // Create a new brush CBrush brush(HS_CROSS,RGB(255,0,0)), *oldBrush; oldBrush = dc.SelectObject(&brush); // Draw a rectangle with the new pen and brush rect.InflateRect(-20, -20); dc.Ellipse(rect); dc.SelectObject(oldPen); dc.SelectObject(oldBrush); } // Init the application BOOL CApp::InitInstance() { m_pMainWnd = new CWindow(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; }

上一篇:Ubuntu下vsftp安装和配置
下一篇:SDUT—2057 模拟题

相关文章

相关评论