1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
BOOL CMapBuilder::DrawTrack(int xStart, int yStart, int xEnd, int yEnd) { BOOL ret = FALSE; HDC hDC = NULL; hDC = m_TrackMask.GetDC(); CDC* memoryDC = CDC::FromHandle(hDC); memoryDC->SetDCPenColor((COLORREF)255); memoryDC->MoveTo(xStart, yStart); ret = memoryDC->LineTo(xEnd, yEnd); m_TrackMask.ReleaseDC(); //COLORREF color = m_TrackMask.GetPixel(0, 0); // For testing return ret; }
And I have fixed your code.
You need to select a pen in the DC.
pDC->SelectObject(GetStockObject(DC_PEN));
This line pDC->SetDCPenColor(RGB(255, 0, 0)); just set a color for a pen selected in DC.
1: 2: 3: 4: 5: 6: 7: 8: 9:
void CCImage_DCDlg::AddLine() { HDC hDC = m_Image.GetDC(); CDC* pDC = CDC::FromHandle(hDC); pDC->SetDCPenColor(RGB(255, 0, 0)); pDC->SelectObject(GetStockObject(DC_PEN)); pDC->MoveTo(0, 0); pDC->LineTo(200, 200); }