首页 > 代码库 > MFC画标尺

MFC画标尺

void CJjjView::OnPaint() {    CPaintDC dc(this);    //屏幕初始化    dc.SetMapMode(MM_LOENGLISH);//0.01in  ;1英寸映射    dc.SetTextAlign(TA_CENTER|TA_BOTTOM);    dc.SetBkMode(TRANSPARENT);    //画尺子主题    CBrush brush(RGB(255,255,0));    CBrush* pOldBrush=dc.SelectObject(&brush);    dc.Rectangle(100,-100,1300,-200);    dc.SelectObject(pOldBrush);    //画刻度    for(int i=125;i<1300;i+=25){        dc.MoveTo(i,-192);        dc.LineTo(i,-200);    }    for(i=150;i<1300;i+=50){        dc.MoveTo(i,-184);        dc.LineTo(i,-200);    }    for(i=200;i<1300;i+=100){        dc.MoveTo(i,-175);        dc.LineTo(i,-200);        CString string;        string.Format(_T("%d"),(i/100)-1);        dc.TextOutA(i,-175,string);    }    //商标        //CRect rect(125,-125,175,-150);    //CString string=_T("晨光");    //dc.DrawText(string,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);    dc.SetTextColor(RGB(192,192,192));    dc.TextOutA(125,-125,"晨光");}

没想到画标尺这么简单,另外这位小兄弟的博客比较有用,简直是后生可畏:

http://www.cnblogs.com/zjutlitao/p/3735223.html

MFC画标尺