多边形也就是由一些连续的直线组成的,所以绘图的代码还是前面的画直线的那两种算法,只不过在鼠标移动的过程中要特别注意记录终点的位置而已,代码中还是存在着bug,画多边形的时候出现了黄色的阴影线,真是奇怪的问题。为了判别是否是多边形的第一条边,加入了一个新变量:bool m_bIsFirstDone;//是否第一条边
void
CMyDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
CDC * pDC = GetDC();
// 状态栏显示坐标值
str.Format( " X:%d,Y:%d " ,point.x,point.y);
if ( ! m_pwndStatusBar)
m_pwndStatusBar = ((CMainFrame * )AfxGetMainWnd()) -> GetStatusBar();
m_pwndStatusBar -> SetPaneText( 2 ,str, 1 );
if (m_dsDrawSort == dsNULL)
return ;
switch (m_dsDrawSort)
{
case dsLine:
SetCursor(m_hDLCursor);
break ;
case dsCircle:
SetCursor(m_hDCCursor);
break ;
}
// 鼠标放开了
if ( ! m_bIsMoseDown)
return ;
pDC -> SetROP2(R2_NOTXORPEN);
switch</
{
// TODO: Add your message handler code here and/or call default
CString str;
CDC * pDC = GetDC();
// 状态栏显示坐标值
str.Format( " X:%d,Y:%d " ,point.x,point.y);
if ( ! m_pwndStatusBar)
m_pwndStatusBar = ((CMainFrame * )AfxGetMainWnd()) -> GetStatusBar();
m_pwndStatusBar -> SetPaneText( 2 ,str, 1 );
if (m_dsDrawSort == dsNULL)
return ;
switch (m_dsDrawSort)
{
case dsLine:
SetCursor(m_hDLCursor);
break ;
case dsCircle:
SetCursor(m_hDCCursor);
break ;
}
// 鼠标放开了
if ( ! m_bIsMoseDown)
return ;
pDC -> SetROP2(R2_NOTXORPEN);
switch</