资源简介
一个基于MFC的画图程序,可以画直线,圆,矩形,多边形等。
代码片段和文件信息
// Circle.cpp: implementation of the CCircle class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “Testwork.h“
#include “Circle.h“
#include “Math.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCircle::CCircle()
{}
CCircle::CCircle(CPoint m_begain_ptCPoint m_final_pt)
{
this->m_begain_pt=m_begain_pt;
this->m_final_pt=m_final_pt;
this->m_IsSelected=false;
this->m_IsDelete=false;
m_radius=CMathOp::Dist((float)m_begain_pt.x(float)m_begain_pt.y(float)m_final_pt.x(float)m_final_pt.y);
}
CCircle::~CCircle()
{}
void CCircle::DrawGraph(CPoint ACPoint BCPen &dpen)
{
m_dc->SelectStockobject(NULL_BRUSH);
m_dc->Selectobject(dpen);
float radius=CMathOp::Dist((float)A.x(float)A.y(float)B.x(float)B.y);
m_dc->Ellipse(A.x-(int)radiusA.y-(int)radiusA.x+(int)radiusA.y+(int)radius);
}
void CCircle::DrawPoint()
{
m_dc->Ellipse(tmp_lt_pt.x-2tmp_lt_pt.y-2tmp_lt_pt.x+2tmp_lt_pt.y+2);
m_dc->Ellipse(tmp_lb_pt.x-2tmp_lb_pt.y-2tmp_lb_pt.x+2tmp_lb_pt.y+2);
m_dc->Ellipse(tmp_rt_pt.x-2tmp_rt_pt.y-2tmp_rt_pt.x+2tmp_rt_pt.y+2);
m_dc->Ellipse(tmp_rb_pt.x-2tmp_rb_pt.y-2tmp_rb_pt.x+2tmp_rb_pt.y+2);
}
void CCircle::DrawGraph()
{
if(m_IsSelected==true)
CCircle::DrawPoint();
if(m_IsDelete==false)
{
m_dc->Selectobject(m_IsSelected==true?select_pen:draw_pen);
m_dc->SelectStockobject(NULL_BRUSH);
m_dc->Ellipse(m_begain_pt.x-(int)m_radiusm_begain_pt.y-(int)m_radiusm_begain_pt.x+(int)m_radiusm_begain_pt.y+(int)m_radius);
}
}
void CCircle::EraseGraph()
{
m_dc->Selectobject(erase_pen);
m_dc->SelectStockobject(NULL_BRUSH);
CCircle::DrawPoint();
m_dc->Ellipse(m_begain_pt.x-(int)m_radiusm_begain_pt.y-(int)m_radiusm_begain_pt.x+(int)m_radiusm_begain_pt.y+(int)m_radius);
}
void CCircle::Offset(int dxint dy)
{
m_begain_pt.x += dx;
m_begain_pt.y += dy;
m_final_pt.x += dx;
m_final_pt.y += dy;
CCircle::InitBox();
}
void CCircle::DrawPixel(CPoint ACPen &dpen)
{
m_dc->Selectobject(dpen);
m_dc->Ellipse(A.x-2A.y-2A.x+2A.y+2);
}
void CCircle::InitBox()
{
this->m_left=m_begain_pt.x-(int)m_radius;
this->m_right=m_begain_pt.x+(int)m_radius;
this->m_top=m_begain_pt.y-(int)m_radius;
this->m_bottom=m_begain_pt.y+(int)m_radius;
tmp_lt_pt.x=m_left;tmp_lt_pt.y=m_top;
tmp_lb_pt.x=m_left;tmp_lb_pt.y=m_bottom;
tmp_rt_pt.x=m_right;tmp_rt_pt.y=m_top;
tmp_rb_pt.x=m_right;tmp_rb_pt.y=m_bottom;
}
int CCircle::IsInBox(CPoint tmp_pt)
{
int dis=(int)CMathOp::Dist((float)tmp_pt.x(float)tmp_pt.y(float)m_begain_pt.x(float)m_begain_pt.y);
if(dis<=8)
return 2;
else if(dis<=m_radius+10 && dis>=m_radius-10)
return 1;
else
return 0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3692 2012-08-15 10:53 Testwork\Circle.cpp
文件 1040 2012-08-15 10:52 Testwork\Circle.h
文件 1157 2012-08-11 16:10 Testwork\Command.cpp
文件 920 2012-08-23 11:02 Testwork\Command.h
文件 1602 2012-08-23 11:02 Testwork\CommandCircle.cpp
文件 839 2012-08-10 16:05 Testwork\CommandCircle.h
文件 1255 2012-08-24 10:02 Testwork\Commandcurve.cpp
文件 780 2012-08-10 16:05 Testwork\Commandcurve.h
文件 1621 2012-09-03 12:50 Testwork\CommandLine.cpp
文件 777 2012-08-10 16:05 Testwork\CommandLine.h
文件 1613 2012-08-23 11:02 Testwork\CommandRectangle.cpp
文件 822 2012-08-13 10:30 Testwork\CommandRectangle.h
文件 603 2012-08-30 10:25 Testwork\Compass.cpp
文件 544 2012-08-30 10:23 Testwork\Compass.h
文件 789 2012-08-31 17:39 Testwork\Compass1.cpp
文件 721 2012-08-31 09:46 Testwork\Compass1.h
文件 798 2012-08-11 11:07 Testwork\Curve.cpp
文件 668 2012-08-11 11:05 Testwork\Curve.h
文件 22314 2012-09-05 09:18 Testwork\Debug\BmpButton.obj
文件 0 2012-09-05 09:18 Testwork\Debug\BmpButton.sbr
文件 18191 2012-09-03 11:20 Testwork\Debug\Circle.obj
文件 0 2012-09-03 11:20 Testwork\Debug\Circle.sbr
文件 10016 2012-09-03 11:20 Testwork\Debug\Command.obj
文件 0 2012-09-03 11:20 Testwork\Debug\Command.sbr
文件 8868 2012-09-03 11:20 Testwork\Debug\CommandCircle.obj
文件 0 2012-09-03 11:20 Testwork\Debug\CommandCircle.sbr
文件 8654 2012-09-03 11:20 Testwork\Debug\Commandcurve.obj
文件 0 2012-09-03 11:20 Testwork\Debug\Commandcurve.sbr
文件 7908 2012-09-05 09:18 Testwork\Debug\CommandLine.obj
文件 0 2012-09-05 09:18 Testwork\Debug\CommandLine.sbr
............此处省略101个文件信息
相关资源
- 基于Scintilla开发的MFC多文档源代码编
- MFC实现简易绘图软件
- 2个线程同时运行MFC
- 银行排号系统MFC实现和控制台实现
- 在MFC的对话框类中向闭合区域填充颜
- MFC+OpenGL 读取并显示STL三维模型
- MFC与SQL Server
- MFC编写的图书管理系统,用到数据库
- MFC 版俄罗斯方块
- 基于MFC的UDP通信实现
- 自定义消息
- mfc 实现迷宫程序
- 记账本小程序
- vc++6.0 MFC 写的贪吃蛇工程源码
- MFC 绘图工具 绘制简单 图形文档和代
- MFC平台下的电子词典
- MFC 贪吃蛇
- MFC教师住房管理系统和矩阵运算以及
- 高斯投影坐标正反算MFC
- mfc实现的考试出题系统
- VC++之MFC类库中文手册含MFC控件使用手
- 利用MFC和OpenCV实现的图片浏览器,支
- MFC编写的贪吃蛇源码
- 火车订票系统MFC
- 基于VC++MFC程序设计简易画图板
- 用MFC做的模拟时钟指针,还有日历对
- VC基于对话框的MFC程序,实现字符统计
- 基于MFC对话框扫雷程序
- MFC各种重绘漂亮按钮
- 简易打字游戏程序 MFC
评论
共有 条评论