这段东西哪里错了?

naixi 2002-05-07 08:23:06
程序编译通过,执行的时候发生错误,再调试弹出个框框说有个断点在0x409ab5
估计后面算面积的没错,是中间模板的错误
void CMyHomeworkView::GetRgnArea()
{
area1=0;
int i,j;
CRect rect;
CPoint* m_points;
int m_nPoints;
m_nPoints=0;
CMyHomeworkDoc* pDoc = GetDocument();

CTypedPtrList<CObList,CStroke*>& strokeList = pDoc->m_strokeList;
POSITION pos = strokeList.GetHeadPosition();
while (pos != NULL)
{
CStroke* pStroke = strokeList.GetNext(pos);
m_nPoints = m_nPoints+m_pStrokeCur->m_pointArray.GetSize();
}
m_points = new CPoint[m_nPoints];

CTypedPtrList<CObList,CStroke*>& strokeList1 = pDoc->m_strokeList;
POSITION pos1 = strokeList1.GetHeadPosition();
while (pos1 != NULL)
{
CStroke* pStroke1 = strokeList1.GetNext(pos1);
for(i = 0; i<m_nPoints ; i++)
m_points[i] = m_pStrokeCur->m_pointArray[i];
}

CRgn rgn;
rgn.CreatePolygonRgn(m_points, m_nPoints, ALTERNATE);
rgn.GetRgnBox(&rect);

CPoint point;
for( i = rect.top ; i<rect.bottom;i++)
{
for( j = rect.left; j<rect.right ; j++)
{
point.x = j; point.y = i;
if(rgn.PtInRegion(point))
area1 ++;
}
}
delete[] m_points;
}


...全文
65 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
naixi 2002-05-07
  • 打赏
  • 举报
回复
小男孩,我也发觉了呀,和你修改的差不离了,多谢
xqing157 2002-05-07
  • 打赏
  • 举报
回复
CStroke* pStroke = strokeList.GetNext(pos);
m_nPoints = m_nPoints+m_pStrokeCur->m_pointArray.GetSize();

pStroke和m_pStrokeCur什么关系啊,不懂(水平有限)
xqing157 2002-05-07
  • 打赏
  • 举报
回复
m_pStrokeCur是什么东西?
yu_hl 2002-05-07
  • 打赏
  • 举报
回复
你原来的程序数组越界。
倒,变量用的混乱。:(

CTypedPtrList<CObList,CStroke*>& strokeList = pDoc->m_strokeList;
POSITION pos = strokeList.GetHeadPosition();
while (pos != NULL)
{
CStroke* pStroke = strokeList.GetNext(pos);
m_nPoints = m_nPoints+pStroke ->m_pointArray.GetSize();
}
m_points = new CPoint[m_nPoints];

POSITION pos = strokeList.GetHeadPosition();
int index = 0;
while (pos1 != NULL)
{
CStroke* pStroke = strokeList.GetNext(pos);
for(i = 0; i<pStroke->m_pointArray.GetSize();i++)
m_points[index++] = pStroke ->m_pointArray[i];
}
naixi 2002-05-07
  • 打赏
  • 举报
回复
小南海,我知道错误了,呵呵,分漫漫给你,如果有问题我接着问,等我弄好了就揭贴
naixi 2002-05-07
  • 打赏
  • 举报
回复
跟踪吗?。。。。。没学过
262行是这个:
{ ASSERT(nIndex >= 0 && nIndex < m_nSize);
我想是不是数组的个数的问题?
yu_hl 2002-05-07
  • 打赏
  • 举报
回复
跟踪一下这段代码,看哪句错。
naixi 2002-05-07
  • 打赏
  • 举报
回复
还是错Y
老是说afxtempl第262行错
yu_hl 2002-05-07
  • 打赏
  • 举报
回复
CTypedPtrList<CObList,CStroke*>& strokeList1 = pDoc->m_strokeList;
POSITION pos1 = strokeList1.GetHeadPosition();
int index = 0;
while (pos1 != NULL)
{
CStroke* pStroke1 = strokeList1.GetNext(pos1);
for(i = 0; i<m_pStrokeCur->m_pointArray.GetSize();i++)
m_points[index++] = m_pStrokeCur->m_pointArray[i];
}

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧