THis code is straight out of a text book but the color is always black. It is suppossed to draw black with one mouse button and red with the other. Can anyone spot a problem? Thanks.
************
void CMouseDlg::OnMo useMove(UINT nFlags, CPoint point)
{
if (((nFlags & MK_LBUTTON) == MK_LBUTTON) ||
((nFlags & MK_RBUTTON) == MK_RBUTTON))
{
CPen lpen;
CClientDC dc(this);
CPen* pPrevPen = NULL;
if ((nFlags & MK_LBUTTON) == MK_LBUTTON)
CPen lpen(PS_SOLID, 16, RGB(255,0,0));
if ((nFlags & MK_RBUTTON) == MK_RBUTTON)
CPen lpen(PS_SOLID, 16, RGB(255,0,0));
pPrevPen = dc.SelectObject (&lpen);
dc.MoveTo(m_iPr evx, m_iPrevy);
dc.LineTo(point .x, point.y);
m_iPrevx = point.x;
m_iPrevy = point.y;
dc.SelectObject (pPrevPen);
}
CDialog::OnMous eMove(nFlags, point);
}
void CMouseDlg::OnLB uttonDown(UINT nFlags, CPoint point)
{
m_iPrevx = point.x;
m_iPrevy = point.y;
CDialog::OnLBut tonDown(nFlags, point);
}
void CMouseDlg::OnRB uttonDown(UINT nFlags, CPoint point)
{
m_iPrevx = point.x;
m_iPrevy = point.y;
CDialog::OnRBut tonDown(nFlags, point);
}
*************** ****
************
void CMouseDlg::OnMo useMove(UINT nFlags, CPoint point)
{
if (((nFlags & MK_LBUTTON) == MK_LBUTTON) ||
((nFlags & MK_RBUTTON) == MK_RBUTTON))
{
CPen lpen;
CClientDC dc(this);
CPen* pPrevPen = NULL;
if ((nFlags & MK_LBUTTON) == MK_LBUTTON)
CPen lpen(PS_SOLID, 16, RGB(255,0,0));
if ((nFlags & MK_RBUTTON) == MK_RBUTTON)
CPen lpen(PS_SOLID, 16, RGB(255,0,0));
pPrevPen = dc.SelectObject (&lpen);
dc.MoveTo(m_iPr evx, m_iPrevy);
dc.LineTo(point .x, point.y);
m_iPrevx = point.x;
m_iPrevy = point.y;
dc.SelectObject (pPrevPen);
}
CDialog::OnMous eMove(nFlags, point);
}
void CMouseDlg::OnLB uttonDown(UINT nFlags, CPoint point)
{
m_iPrevx = point.x;
m_iPrevy = point.y;
CDialog::OnLBut tonDown(nFlags, point);
}
void CMouseDlg::OnRB uttonDown(UINT nFlags, CPoint point)
{
m_iPrevx = point.x;
m_iPrevy = point.y;
CDialog::OnRBut tonDown(nFlags, point);
}
*************** ****
Comment