| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 281 人关注过本帖
标题:[求助]两个矩形的相交为外接巨型画椭圆问题
收藏  订阅  推荐  打印 
哈狄斯
Rank: 1
等级:新手上路
帖子:22
积分:320
注册:2006-3-14
[求助]两个矩形的相交为外接巨型画椭圆问题

在视图类声明成员变量

public:
CRect m_rRect1;
cRect m_rRect2;

在构造函数初始化

CRecRecView::CRecRecView():m_rRect1(50,50,250,200),m_rRect2(100,120,300,400)


void CRecRecView::OnDraw(CDC* pDC)
{
CRecRecDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x1,y1;
int x2,y2;
if(m_rRect1.left<m_rRect2.left)
x1=m_rRect2.left;
else
x1=m_rRect1.left;
if(m_rRect1.top<m_rRect2.top)
y1=m_rRect2.top;
else
y1=m_rRect1.top;
if(m_rRect1.right<m_rRect2.right)
x2=m_rRect2.right;
else
x2=m_rRect1.right;
if(m_rRect1.bottom<m_rRect2.bottom)
y2=m_rRect2.bottom;
else
y2=m_rRect1.bottom;
pDC->Ellipse(x1,x2,y1,y2);
}

--------------------Configuration: RecRec - Win32 Debug--------------------
Compiling...
RecRec.cpp
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2146: syntax error : missing ';' before identifier 'm_rRect2'
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'cRect' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'm_rRect2' : missing storage-class or type specifiers
RecRecView.cpp
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2146: syntax error : missing ';' before identifier 'm_rRect2'
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'cRect' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\recrec\recrecview.h(17) : error C2501: 'm_rRect2' : missing storage-class or type specifiers
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(36) : error C2614: 'CRecRecView' : illegal member initialization: 'm_rRect2' is not a base or member
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(63) : error C2065: 'm_rRect2' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(63) : error C2228: left of '.left' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(64) : error C2228: left of '.left' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(67) : error C2228: left of '.top' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(68) : error C2228: left of '.top' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(71) : error C2228: left of '.right' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(72) : error C2228: left of '.right' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(75) : error C2228: left of '.bottom' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\RecRec\RecRecView.cpp(76) : error C2228: left of '.bottom' must have class/struct/union type
Generating Code...
Error executing cl.exe.

RecRec.exe - 16 error(s), 0 warning(s)

不知道哪错了,谢谢 ,辛苦大家!!帮忙指点,谢谢了!!!

搜索更多相关主题的帖子: 椭圆  矩形  CRecRecView  CDC  int  
2006-3-27 22:00
踏魔狼
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:22
帖子:1289
积分:13340
注册:2005-9-22

如此初始化,不错才怪!

=×&D o I p R e E n C g T l X&×=
2006-3-27 22:06
踏魔狼
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:22
帖子:1289
积分:13340
注册:2005-9-22

CRecRecView::CRecRecView()

m_rRect1(50,50,250,200);m_rRect2(100,120,300,400);

=×&D o I p R e E n C g T l X&×=
2006-3-27 22:08
myajax95
Rank: 12Rank: 12Rank: 12
等级:版主
威望:30
帖子:2978
积分:30680
注册:2006-3-5

改掉红色的两处应该就没什么错了。

public:
CRect m_rRect1;
CRect m_rRect2;

CRecRecView::CRecRecView():m_rRect1(50,50,250,200),m_rRect2(100,120,300,400)

{}

void CRecRecView::OnDraw(CDC* pDC)
{
CRecRecDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x1,y1;
int x2,y2;
if(m_rRect1.left<m_rRect2.left)
x1=m_rRect2.left;
else
x1=m_rRect1.left;
if(m_rRect1.top<m_rRect2.top)
y1=m_rRect2.top;
else
y1=m_rRect1.top;
if(m_rRect1.right<m_rRect2.right)
x2=m_rRect2.right;
else
x2=m_rRect1.right;
if(m_rRect1.bottom<m_rRect2.bottom)
y2=m_rRect2.bottom;
else
y2=m_rRect1.bottom;
pDC->Ellipse(x1,x2,y1,y2);
}


http://myajax95.bc-cn.net/
2006-3-28 16:43
哈狄斯
Rank: 1
等级:新手上路
帖子:22
积分:320
注册:2006-3-14

谢谢指教!!!!!

2006-3-30 12:25
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.049606 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved