代码是这样的
HRESULT CGrid::OnDraw(ATL_DRAWINFO& di)
{
MoveToEx(di.hdcDraw,0,0,NULL);
LineTo(di.hdcDraw,100,100);
return S_OK;
}
坐标问题是不是MM_HIENGLISH的坐标
同意楼上的,完全是坐标问题,线形画刷也可以不写,直接用默认的。建议看一下msdn里面的ATL教程,仿照那个OnDraw函数,一定能搞定。
ps:如果你用vs.net的调试器看是可以看到你画的线的。如果放到网页上,坐标变了,就可能看不到了。
下面是atl教程里面的ondraw函数。
HRESULT CPolyCtl::OnDraw(ATL_DRAWINFO& di)
{
RECT& rc = *(RECT*)di.prcBounds;
HDC hdc = di.hdcDraw;
COLORREF colFore;
HBRUSH hOldBrush, hBrush;
HPEN hOldPen, hPen;
// Translate m_colFore into a COLORREF type
OleTranslateColor(m_clrFillColor, NULL, &colFore);
// Create and select the colors to draw the circle
hPen = (HPEN)GetStockObject(BLACK_PEN);
hOldPen = (HPEN)SelectObject(hdc, hPen);
hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);
Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
// Create and select the brush that will be used to fill the polygon
hBrush = CreateSolidBrush(colFore);
SelectObject(hdc, hBrush);
CalcPoints(rc);
Polygon(hdc, &m_arrPoint[0], m_nSides);
// Select back the old pen and brush and delete the brush we created
SelectObject(hdc, hOldPen);
SelectObject(hdc, hOldBrush);
DeleteObject(hBrush);
return S_OK;
}