Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在MFC单个文档中存储坐标?_C++_Mfc - Fatal编程技术网

C++ 如何在MFC单个文档中存储坐标?

C++ 如何在MFC单个文档中存储坐标?,c++,mfc,C++,Mfc,我正在做一个绘图工具的小项目 我使用直线绘制多边形,因此我使用CList m_Points存储每条直线的端点 这是我的密码: void CDrawToolView::OnLButtonUp(UINT nFlags, CPoint point) { . . . CList<CPoint,CPoint> m_Points; m_Points.AddTail(point); . . . } 然后在对话框中,单击“确定”时,读取CList

我正在做一个绘图工具的小项目

我使用直线绘制多边形,因此我使用
CList m_Points
存储每条直线的端点

这是我的密码:

void CDrawToolView::OnLButtonUp(UINT nFlags, CPoint point)
{
   .
   .
   .
   CList<CPoint,CPoint> m_Points; 
   m_Points.AddTail(point);
   . 
   .
   .
}
然后在对话框中,单击“确定”时,读取
CList points
中的所有点:

void CPropertyDlg::OnBnClickedOk()
{
    CList<CPoint,CPoint> Points; 
    Points.AddTail(polypoint);
    POSITION pos = Points.GetHeadPosition();
    while( pos != NULL )
    {
       int i = 0;
       element = Points.GetNext(pos);
       polygon_x[i] = element.x;
       polygon_y[i] = element.y;
       i ++;
    }
}
void CPropertyDlg::OnBnClickedOk()
{
阴蒂点;
点。AddTail(多点);
位置位置=点。GetHeadPosition();
while(pos!=NULL)
{
int i=0;
元素=点。获取下一个(位置);
多边形_x[i]=元素x;
多边形y[i]=元素y;
i++;
}
}
运行程序时,
CObject::operator=”:无法访问类“CObject”中声明的私有成员
,如何解决该问题


此外,我可以使用此方法将点传递给对话框吗?

将CPropertyDlg的m_点成员声明为
CList*
,并传递指向此对话框的指针:

void CDrawToolView::OnEditProperty()
{
    CPropertyDlg dlg;  
    dlg.Points = &m_Points;
    if (dlg.DoModal() == IDOK)
    {   
        //m_Points = dlg.Points;   // not necessary because Points is changed in-place
    }
}
现有代码中的问题是,您试图通过值传递
CList
,这需要复制整个对象。MFC作者不允许将
operator=
设为私有


顺便说一句,如果您正试图实现绘图功能,请查看MFC示例DRAWCLI。

MFC:啊,很高兴我不必穿听起来像那样的衬衫,这不是在stackoverflow上要问的问题类型。你已经问了几个围绕着同一主题的问题:如何在C++中传递复杂的数据。我会建议拿起一个好的介绍和工作,通过这一点。
void CDrawToolView::OnEditProperty()
{
    CPropertyDlg dlg;  
    dlg.Points = &m_Points;
    if (dlg.DoModal() == IDOK)
    {   
        //m_Points = dlg.Points;   // not necessary because Points is changed in-place
    }
}