VC如何画坐标轴
发布网友
发布时间:2022-04-29 00:55
我来回答
共5个回答
热心网友
时间:2022-06-26 22:09
CClientDC dc(this);
CDC* pDC=&dc;
//////////定义画笔
CPen pen(1,1,RGB(0,0,255)),pen1(1,1,RGB(255,0,0));
CPen *pold_pen=pDC->SelectObject(&pen);
//////////定义画笔
CRect rect;
GetClientRect(&rect);
rect.top+=100;
rect.left+=100;
rect.right-=100;
rect.bottom-=100;
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetViewportOrg(10,10);
//pDC->SetViewportOrg(900,5000);
pDC->SetViewportExt(rect.right-rect.left,rect.bottom-rect.top);//设置视口范围
pDC->SetWindowOrg(10,10);
//pDC->SetViewportOrg(900,5000);
pDC->SetWindowExt(1800,10000);
pDC->MoveTo(0,5000);
pDC->LineTo(1800,5000);
pDC->MoveTo(100,0);
pDC->LineTo(100,10000);
pDC->MoveTo(100,11000);
pDC->LineTo(1800,11000);
//以上部分画的是坐标
for(int j=0;j<16;j++)
{
CPen pen(0,1,RGB(0,255,255));
CString cs;
cs.Format("%d ",j);
pDC->TextOut(100+j*M/2,5000,cs);
CRect rect(100+j*M/2,5000,100+j*M/2+20,5000+20);
pDC->Ellipse(&rect);//////////////////写坐标值
}
for(j=-3;j<4;j++)
{
CString cs;
double t=j*0.5;
cs.Format("%2.1f",t);
pDC->TextOut(100,(int)(5000.0-t*M*4),cs);
这个里面有你想要的,你自己看下,话坐标写作表都有,我自己不想整理了,
另外,团IDC网上有许多产品团购,便宜有口碑
热心网友
时间:2022-06-26 22:10
//画坐标 CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
CPen pen,*pOldPen;
pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
pOldPen=dc.SelectObject(&pen);
dc.MoveTo(rect.right-10,rect.bottom-30);
dc.LineTo(rect.right-20,rect.bottom-27);
dc.MoveTo(rect.right-10,rect.bottom-30);
dc.LineTo(rect.right-20,rect.bottom-33);
dc.MoveTo(rect.right-10,rect.bottom-30);
dc.LineTo(10,rect.bottom-30);
dc.LineTo(10,10);
dc.LineTo(7,20);
dc.MoveTo(10,10);
dc.LineTo(13,20);
dc.SelectObject(pOldPen);
pen.DeleteObject();
热心网友
时间:2022-06-26 22:10
CClientDC dc(this);
CDC* pDC=&dc;
//////////定义画笔
CPen pen(1,1,RGB(0,0,255)),pen1(1,1,RGB(255,0,0));
CPen *pold_pen=pDC->SelectObject(&pen);
//////////定义画笔
CRect rect;
GetClientRect(&rect);
rect.top+=100;
rect.left+=100;
rect.right-=100;
rect.bottom-=100;
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetViewportOrg(10,10);
//pDC->SetViewportOrg(900,5000);
pDC->SetViewportExt(rect.right-rect.left,rect.bottom-rect.top);//设置视口范围
pDC->SetWindowOrg(10,10);
//pDC->SetViewportOrg(900,5000);
pDC->SetWindowExt(1800,10000);
pDC->MoveTo(0,5000);
pDC->LineTo(1800,5000);
pDC->MoveTo(100,0);
pDC->LineTo(100,10000);
pDC->MoveTo(100,11000);
pDC->LineTo(1800,11000);
//以上部分画的是坐标
for(int j=0;j<16;j++)
{
CPen pen(0,1,RGB(0,255,255));
CString cs;
cs.Format("%d ",j);
pDC->TextOut(100+j*M/2,5000,cs);
CRect rect(100+j*M/2,5000,100+j*M/2+20,5000+20);
pDC->Ellipse(&rect);//////////////////写坐标值
}
for(j=-3;j<4;j++)
{
CString cs;
double t=j*0.5;
cs.Format("%2.1f",t);
pDC->TextOut(100,(int)(5000.0-t*M*4),cs);
这个里面有你想要的,你自己看下,话坐标写作表都有,我自己不想整理了,
另外,站长团上有产品团购,便宜有保证
热心网友
时间:2022-06-26 22:11
也可以用moveto(),lineto() 多画几次,呵呵
热心网友
时间:2022-06-26 22:11
moveto(),lineto()追问如何画出箭头和标出x,y