主题:请教各位运行的程序会死,为什么?
void CEleView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->SetCapture();
this->m_ldPoint = point;
CDC *dc = this->GetDC();
if(dc == NULL)
return;
if(this->m_element != NULL)
this->m_element->Draw(dc);
this->m_element = NULL;
switch(this->m_toolFlag.m_createtype)
{
case ID_SELECT:
this->m_element = this->GetDocument()->m_list.IsSelect(point);
if(this->m_element != NULL)
{
this->m_element->HighShow(dc,1);
C_Complex *complex = static_cast<C_Complex*>(this->m_element);
complex->m_point = complex->SelectPoint(point);
if(complex->m_point != NULL)
complex->m_point->HighShow(dc,2);
}
break;
default:
switch(this->m_toolFlag.m_createtype)
{
case ID_WIRE:
do{
C_Point p1(point,this->m_toolFlag.m_color,5);
C_Line line(point,point,2,PS_SOLID,this->m_toolFlag.m_color);
this->m_element = new C_Wire(p1,p1,line);
this->m_element->Draw(dc);
}while(0);
break;
default:
break;
}
}
dc->ReleaseOutputDC();
this->ReleaseDC(dc);
//CScrollView::OnLButtonDown(nFlags, point);
}
void CEleView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->m_luPoint = point;
CDC *dc = this->GetDC();
if(dc == NULL)
return;
switch(this->m_toolFlag.m_createtype)
{
case ID_SELECT:
if(this->m_element != NULL)
this->m_element->HighShow(dc,1);
break;
default:
switch(this->m_toolFlag.m_createtype)
{
case ID_WIRE:
if(this->m_element != NULL)
{
this->m_element->Draw(dc);
this->GetDocument()->m_list.Add(this->m_element);
delete this->m_element;
this->m_element = NULL;
}
break;
default:
break;
}
}
//C_List *m = &(this->GetDocument()->m_list);
this->ReleaseDC(dc);
ReleaseCapture();
//CScrollView::OnLButtonUp(nFlags, point);
}
void CEleView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->m_mmPoint = point;
CDC *dc = this->GetDC();
if(dc == NULL)
return;
switch(this->m_toolFlag.m_createtype)
{
case ID_SELECT:
if(this->m_element != NULL)
{
C_Complex *complex = static_cast<C_Complex*>(this->m_element);
complex->HighShow(dc,1);
if(complex->m_point != NULL && (nFlags & MK_LBUTTON))
{
this->InvalidateRect(&complex->m_rect,1);
if(complex->ChangePoint(point))
{
complex->HighShow(dc,1);
}
}
else
if(nFlags & MK_LBUTTON)
{
if(this->m_element->Move(this->m_mmPoint - this->m_ldPoint))
{
this->InvalidateRect(&complex->m_rect,1);
this->m_element->HighShow(dc,1);
}
this->m_ldPoint = point;
}
else
{
complex->m_point = complex->SelectPoint(point);
if(complex->m_point != NULL)
complex->m_point->HighShow(dc,2);
}
}
break;
default:
switch(this->m_toolFlag.m_createtype)
{
case ID_WIRE:
if(this->m_element != NULL &&
this->m_element->ReturnType() == ID_WIRE)
{
C_Wire *pWire = static_cast<C_Wire*>(this->m_element);
this->InvalidateRect(&pWire->m_rect);
pWire->m_point = pWire->m_endPoint;
pWire->ChangePoint(point);
pWire->m_point = NULL;
}
break;
default:
break;
}
}
dc->ReleaseOutputDC();
//CScrollView::OnMouseMove(nFlags, point);
}
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->SetCapture();
this->m_ldPoint = point;
CDC *dc = this->GetDC();
if(dc == NULL)
return;
if(this->m_element != NULL)
this->m_element->Draw(dc);
this->m_element = NULL;
switch(this->m_toolFlag.m_createtype)
{
case ID_SELECT:
this->m_element = this->GetDocument()->m_list.IsSelect(point);
if(this->m_element != NULL)
{
this->m_element->HighShow(dc,1);
C_Complex *complex = static_cast<C_Complex*>(this->m_element);
complex->m_point = complex->SelectPoint(point);
if(complex->m_point != NULL)
complex->m_point->HighShow(dc,2);
}
break;
default:
switch(this->m_toolFlag.m_createtype)
{
case ID_WIRE:
do{
C_Point p1(point,this->m_toolFlag.m_color,5);
C_Line line(point,point,2,PS_SOLID,this->m_toolFlag.m_color);
this->m_element = new C_Wire(p1,p1,line);
this->m_element->Draw(dc);
}while(0);
break;
default:
break;
}
}
dc->ReleaseOutputDC();
this->ReleaseDC(dc);
//CScrollView::OnLButtonDown(nFlags, point);
}
void CEleView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->m_luPoint = point;
CDC *dc = this->GetDC();
if(dc == NULL)
return;
switch(this->m_toolFlag.m_createtype)
{
case ID_SELECT:
if(this->m_element != NULL)
this->m_element->HighShow(dc,1);
break;
default:
switch(this->m_toolFlag.m_createtype)
{
case ID_WIRE:
if(this->m_element != NULL)
{
this->m_element->Draw(dc);
this->GetDocument()->m_list.Add(this->m_element);
delete this->m_element;
this->m_element = NULL;
}
break;
default:
break;
}
}
//C_List *m = &(this->GetDocument()->m_list);
this->ReleaseDC(dc);
ReleaseCapture();
//CScrollView::OnLButtonUp(nFlags, point);
}
void CEleView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->m_mmPoint = point;
CDC *dc = this->GetDC();
if(dc == NULL)
return;
switch(this->m_toolFlag.m_createtype)
{
case ID_SELECT:
if(this->m_element != NULL)
{
C_Complex *complex = static_cast<C_Complex*>(this->m_element);
complex->HighShow(dc,1);
if(complex->m_point != NULL && (nFlags & MK_LBUTTON))
{
this->InvalidateRect(&complex->m_rect,1);
if(complex->ChangePoint(point))
{
complex->HighShow(dc,1);
}
}
else
if(nFlags & MK_LBUTTON)
{
if(this->m_element->Move(this->m_mmPoint - this->m_ldPoint))
{
this->InvalidateRect(&complex->m_rect,1);
this->m_element->HighShow(dc,1);
}
this->m_ldPoint = point;
}
else
{
complex->m_point = complex->SelectPoint(point);
if(complex->m_point != NULL)
complex->m_point->HighShow(dc,2);
}
}
break;
default:
switch(this->m_toolFlag.m_createtype)
{
case ID_WIRE:
if(this->m_element != NULL &&
this->m_element->ReturnType() == ID_WIRE)
{
C_Wire *pWire = static_cast<C_Wire*>(this->m_element);
this->InvalidateRect(&pWire->m_rect);
pWire->m_point = pWire->m_endPoint;
pWire->ChangePoint(point);
pWire->m_point = NULL;
}
break;
default:
break;
}
}
dc->ReleaseOutputDC();
//CScrollView::OnMouseMove(nFlags, point);
}