请问标尺是不是对应一个类啊,是什么类?
不知道有没有这个类,不过我自已写过标尺的函数贴出来希望对你有帮助.
void showfreeunit(HDC hdc,int x,int y,int w,int h)
{
char txt[4];
int i;
HPEN hpen,nullpen;
hpen=CreatePen(PS_SOLID,1,RGB(0,0,0));
nullpen=CreatePen(PS_SOLID,1,RGB(255,255,255));
HFONT hfont;
hfont=CreateFont(
12, 6, 0, 0, 0, 0, 0, 0,
GB2312_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_DONTCARE,
"Times New Roman"
);
SelectObject(hdc,hfont);
HBRUSH brush;
brush=CreateSolidBrush(RGB(255,255,255));
SelectObject(hdc,brush);
MoveToEx(hdc,30,y,NULL);
LineTo(hdc,30,2048);
MoveToEx(hdc,x,50,NULL);
LineTo(hdc,2048,50);
//填充标尺底
SelectObject(hdc,nullpen);
Rectangle(hdc,0,0,2048,50);
Rectangle(hdc,0,0,30,1024);
//水平标尺
SelectObject(hdc,hpen);
for(i=0;i<w+5;i=i+5)
{
if(i%25==0)
{
MoveToEx(hdc,x+i,50,NULL);
LineTo(hdc,x+i,40);
sprintf(txt,"%d",i/5);
TextOut(hdc,x+i,30,txt,strlen(txt));
}
else
{
MoveToEx(hdc,x+i,50,NULL);
LineTo(hdc,x+i,45);
}
}
//垂直标尺
for(i=0;i<h+5;i=i+5)
{
if(i%25==0)
{
MoveToEx(hdc,30,y+i,NULL);
LineTo(hdc,20,y+i);
sprintf(txt,"%d",i/5);
TextOut(hdc,5,y+i,txt,strlen(txt));
}
else
{
MoveToEx(hdc,30,y+i,NULL);
LineTo(hdc,25,y+i);
}
}
//填充原点
SelectObject(hdc,nullpen);
Rectangle(hdc,0,0,30,50);
}