I am doing a small project of drawing tool.
I use line to draw a polygon, so I use CList<CPoint,CPoint> m_Points
to store the end point of each line.
Here is my code:
void CDrawToolView::OnLButtonUp(UINT nFlags, CPoint point)
{
.
.
.
CList<CPoint,CPoint> m_Points;
m_Points.AddTail(point);
.
.
.
}
And I want to pass the points to a dialog. In the calling function:
void CDrawToolView::OnEditProperty()
{
CPropertyDlg dlg;
dlg.Points = m_Points;
if (dlg.DoModal() == IDOK)
{
m_Points = dlg.Points;
}
}
Then in the dialog, when clicking OK, read all the points from CList<CPoint,CPoint> 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 ++;
}
}
When running program, CObject::operator =' : cannot access private member declared in class 'CObject'
, how can I fix that problem?
Besides, can I use this method to pass points to the dialog?