void CChildView::OnPaint()
{
//如果是 0 开始的坐标范围选择,可以用 SetViewportOrg ,也可以用 SetWindowOrg
CPaintDC dc(this);
RECT rc;
GetClientRect( &rc);
pDC->SetMapMode( MM_ANISOTROPIC );
pDC->SetWindowExt( 10000, 10000 );
pDC->SetViewportExt( rc.right / 2, - rc.bottom / 2);
pDC->SetViewportOrg( rc.right / 4, rc.bottom - rc.bottom / 4 );
//pDC->SetWindowOrg( -5000, 15000 );
pDC->Rectangle( 0, 0, 10000, 10000 );
POINT pts[] = { 0, 0, 3000, 2000, 3500, 6000, 7000, 9000 };
pDC->Polyline( pts, sizeof(pts) / sizeof(*pts) );
pDC->SetBkMode( TRANSPARENT );
for ( int i = 0; i < sizeof(pts) / sizeof(*pts) ; ++ i )
{
TCHAR szText[256];
pDC->TextOut( pts[i].x, pts[i].y, szText,
wsprintf ( szText, L"%d, %d", pts[i].x, pts[i].y ) );
}
pDC->TextOut( 10000, 10000, TEXT("1,1"), 3 );
}
void CChildView::OnPaint()
{
// 但如果不是从 0 开始,则坐标 必须由 SetWindowOrg 设置
CPaintDC dc(this);
RECT rc;
GetClientRect( &rc);
dc.Rectangle( rc.right / 4, rc.bottom / 4, rc.right - rc.right / 4, rc.bottom - rc.bottom / 4 );
dc.SetMapMode( MM_ANISOTROPIC );
dc.SetWindowExt( 10000, 10000 );
dc.SetViewportExt( rc.right / 2, - rc.bottom / 2);
//dc.SetViewportOrg( rc.right / 4, rc.bottom - rc.bottom / 4 );
dc.SetWindowOrg( -2000, 17000 );
//dc.Rectangle( 0, 0, 10000, 10000 );
POINT pts[] = { 0, 0, 3000, 2000, 3500, 6000, 7000, 9000 };
dc.Polyline( pts, sizeof(pts) / sizeof(*pts) );
dc.SetBkMode( TRANSPARENT );
for ( int i = 0; i < sizeof(pts) / sizeof(*pts) ; ++ i )
{
TCHAR szText[256];
dc.TextOut( pts[i].x, pts[i].y, szText,
wsprintf ( szText, L"%d, %d", pts[i].x, pts[i].y ) );
}
dc.TextOut( 10000, 10000, TEXT("1,1"), 3 );
}