void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString text;
GetDlgItemText(IDC_SET_CITY, text);
if ("绘制城市" != text) return;
CWnd *pWnd = GetDlgItem(IDC_MAIN_PANEL);
CRect rect;
pWnd->GetClientRect(rect);
this->ClientToScreen(rect);
pWnd->GetClientRect(rect);
if (!rect.PtInRect(point)) return;
City city;
city.r = 50;
city.x = point.x;
city.y = point.y;
text.Format("%C", 65 + m_citys.GetSize());
city.name = text;
m_citys.Add(city);
if (m_pLastCity != NULL){
Edge e;
e.beginCity = m_pLastCity;
e.endCity = &m_citys[m_citys.GetSize()-1];
m_edges.Add(e);
}
m_pLastCity = &m_citys[m_citys.GetSize()-1];
CDialog::OnLButtonDown(nFlags, point);
}
这是我的左键点击的代码 意思应该是点左键生成一个城市,后面右键是也生成城市,但是对相邻的城市不连线。
我现在想解决的问题是
void CMyDlg::OnDrawCitys(CDC *pDC)
{
CClientDC dc(this);
dc.MoveTo();
dc.LineTo();
}
画城市时,不知道MoveTo和LineTo参数填什么
谢谢大神~