我实在是没有招数了。为什么相同的用法,::Ellipse,而::Rectangle会出问题。300分!
lbIlj 2003-08-19 05:10:40 ::Ellipse可以,无论在什么情况下,都不会出什么问题,但是::Rectangle在我的计算机上也可以。在win2000上也没有问题。为什么在别人的win98上就要出问题。有时候第一次画::Rectangle不出来。执行2,3次后就可以了。
//class of draw Ellipse
CDrawEllipse::CDrawEllipse()
{
m_IsMouseLKeyUp = true;
m_IsDrawEllipse = false;
m_IsDownPointIn = false;
}
CDrawEllipse::~CDrawEllipse()
{
}
void CDrawEllipse::OnLButtonDown(CPoint point,
CRect rRect)
{
m_hWnd->SetCapture();
if (rRect.PtInRect(point))
{
m_IsMouseLKeyUp = false;
m_IsDownPointIn = true;//标志点击的点是否在范围内
m_EllipseUpleftPoint = point;
}
}
bool CDrawEllipse::OnLButtonUp(CPoint point,
CRect rRect)
{
::ReleaseCapture();
m_IsMouseLKeyUp = true;
if (m_IsDrawEllipse && m_IsDownPointIn)
{
m_EllipseBottomRightPoint = point;
m_IsDownPointIn = false;
return true;
}
else
{
return false;
}
}
void CDrawEllipse::OnMouseMove(CPoint point,
CRect rRect)
{
::SetROP2(m_hDC, R2_NOTXORPEN);
HBRUSH hBrush;
hBrush = (HBRUSH) ::SelectObject(m_hDC, GetStockObject(NULL_BRUSH));
if (m_IsMouseLKeyUp == false)
{
m_IsDrawEllipse = true;
::Ellipse(m_hDC,
m_EllipseUpleftPoint.x,
m_EllipseUpleftPoint.y,
m_OldEndPoint.x,
m_OldEndPoint.y);
::Ellipse(m_hDC,
m_EllipseUpleftPoint.x,
m_EllipseUpleftPoint.y,
point.x,
point.y);
}
m_OldEndPoint = point;
::SelectObject(m_hDC, hBrush);
::DeleteObject(hBrush);
}
但是::Rectangle
//class of draw rectangle
CDrawRectangle::CDrawRectangle()
{
m_IsMouseLKeyUp = true;
m_IsDrawRect = false;
m_IsDownPointIn = false;
}
CDrawRectangle::~CDrawRectangle()
{
}
void CDrawRectangle::OnLButtonDown(CPoint point,
CRect rRect)
{
m_hWnd->SetCapture();
if (rRect.PtInRect(point))
{
m_IsMouseLKeyUp = false;
m_RectUpleftPoint = point;
m_IsDownPointIn = true;//标志点击的点是否在范围内
}
m_OldBRPoint = point;
}
bool CDrawRectangle::OnLButtonUp(CPoint point,
CRect rRect)
{
::ReleaseCapture();
m_IsMouseLKeyUp = true;
if (m_IsDrawRect && m_IsDownPointIn)
{
m_RectBottomRightPoint = point;
m_IsDownPointIn = false;
return true;
}
else
{
return false;
}
return false;
}
void CDrawRectangle::OnMouseMove(CPoint point,
CRect rRect)
{
::SetROP2(m_hDC, R2_NOTXORPEN);
HBRUSH hBrush;
hBrush = (HBRUSH) ::SelectObject(m_hDC, GetStockObject(NULL_BRUSH));
if (m_IsMouseLKeyUp == false)
{
m_IsDrawRect = true;
::Rectangle(m_hDC,
m_RectUpleftPoint.x,
m_RectUpleftPoint.y,
m_OldBRPoint.x,
m_OldBRPoint.y);
::Rectangle(m_hDC,
m_RectUpleftPoint.x,
m_RectUpleftPoint.y,
point.x,
point.y);
}
m_OldBRPoint = point;
::SelectObject(m_hDC, hBrush);
::DeleteObject(hBrush);
}
希望各位帮忙了。我实在是没有招数了。我最高给不了300!如过谁帮我解决了,我在贴,再送!绝对!
wxjlb@163.com