请大家看看我这段代码:drect:=rect(PageRect.Left,Amountprint,PageRect.Left+round(0.1*(PageRect.Right-PageRect.Left)),Amountprint+2*textheight); drawtext(pp_pz.Printer.Canvas.handle,pchar(inttostr(p_year)+'年'),length(inttostr(p_year)+'年'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);srect:=rect(PageRect.Left,drect.Bottom,round(0.5*(drect.right-drect.left)+drect.Left),drect.Bottom+2*textheight); drawtext(pp_pz.Printer.Canvas.handle,pchar('月'),length('月'),srect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([srect.left,srect.top,srect.right,srect.top,srect.right,srect.bottom,srect.left,srect.bottom,srect.left,srect.top]); srect:=rect(srect.Right,srect.Top,round(0.5*(drect.right-drect.left)+srect.Right),srect.Bottom); drawtext(pp_pz.Printer.Canvas.handle,pchar('日'),length('日'),srect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([srect.left,srect.top,srect.right,srect.top,srect.right,srect.bottom,srect.left,srect.bottom,srect.left,srect.top]); drect:=rect(drect.right,drect.Top,drect.right+round(0.08*(PageRect.Right-PageRect.Left)),srect.Bottom); drawtext(pp_pz.Printer.Canvas.handle,pchar('凭证号'),length('凭证号'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); drect:=rect(drect.right,drect.Top,drect.right+round(0.29*(PageRect.Right-PageRect.Left)),srect.Bottom); drawtext(pp_pz.Printer.Canvas.handle,pchar('摘 要'),length('摘 要'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]); drect:=rect(drect.right,drect.Top,drect.right+round(0.16*(PageRect.Right-PageRect.Left)),srect.Bottom); drawtext(pp_pz.Printer.Canvas.handle,pchar('借方金额'),length('借方金额'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); drect:=rect(drect.right,drect.Top,drect.right+round(0.16*(PageRect.Right-PageRect.Left)),srect.Bottom); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); drawtext(pp_pz.Printer.Canvas.handle,pchar('贷方金额'),length('贷方金额'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]); drect:=rect(drect.right,drect.Top,drect.right+round(0.03*(PageRect.Right-PageRect.Left)),srect.Bottom); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); jrect:=rect(drect.left,drect.Top+round((drect.bottom-drect.top-2*textheight)*0.5),drect.right,drect.Bottom); drawtext(pp_pz.Printer.Canvas.handle,pchar('方向'),length('方向'),jrect,DT_center or DT_wordbreak); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); drect:=rect(drect.right,drect.Top,drect.right+round(0.18*(PageRect.Right-PageRect.Left)),srect.Bottom); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); drawtext(pp_pz.Printer.Canvas.handle,pchar('期末余额'),length('期末余额'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]); // pp_pz.printer.Canvas.pen.Width:=4; // pp_pz.printer.Canvas.pen.Style PolyPolyline(pp_pz.Printer.Canvas.Handle,PolyPolyPoints.List^,PolyLengths.List^,PolyLengths.Count);---------------------------------------------------------- 说明:楼上的,我不想换其他函数,因为我觉得PolyPolyline挺好的,就是怎么把线画粗来就行了!
试试这个看:
procedure TForm1.Button1Click(Sender: TObject);
var
Dc : HDC;
Pt : Array [0..2] of TPoint ;
Count1, count2 : Integer;
Brush : TLogbrush;
hBrush,hPen : LongInt;
Pen : TLOGPEN;
PenPoint : TPoint;
begin
pt[0].x := 100;
pt[0].y := 100;
pt[1].x := 50;
pt[1].y := 150;
pt[2].x := 150;
pt[2].y := 150;
Dc := GetDC(handle);
Brush.lbStyle := BS_SOLID;
Brush.lbColor := clGreen;
Brush.lbHatch := 0;
hBrush := SelectObject(Dc,CreateBrushIndirect(Brush));
PenPoint.x := 2; // Your pen width here.
PenPoint.y := 0;
Pen.lopnStyle := PS_SOLID;
Pen.lopnWidth := PenPoint;
Pen.lopnColor := clRed;
hPen := SelectObject(Dc,CreatePenIndirect(Pen)); // bind your current canvas.
Polygon(DC,pt,3); // replace with your PolyPolyline functions.
SelectObject(DC, hPen);
SelectObject(DC, hBrush);end;
drawtext(pp_pz.Printer.Canvas.handle,pchar(inttostr(p_year)+'年'),length(inttostr(p_year)+'年'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);
addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);srect:=rect(PageRect.Left,drect.Bottom,round(0.5*(drect.right-drect.left)+drect.Left),drect.Bottom+2*textheight);
drawtext(pp_pz.Printer.Canvas.handle,pchar('月'),length('月'),srect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([srect.left,srect.top,srect.right,srect.top,srect.right,srect.bottom,srect.left,srect.bottom,srect.left,srect.top]);
srect:=rect(srect.Right,srect.Top,round(0.5*(drect.right-drect.left)+srect.Right),srect.Bottom); drawtext(pp_pz.Printer.Canvas.handle,pchar('日'),length('日'),srect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);
addpolyline([srect.left,srect.top,srect.right,srect.top,srect.right,srect.bottom,srect.left,srect.bottom,srect.left,srect.top]);
drect:=rect(drect.right,drect.Top,drect.right+round(0.08*(PageRect.Right-PageRect.Left)),srect.Bottom);
drawtext(pp_pz.Printer.Canvas.handle,pchar('凭证号'),length('凭证号'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE);
addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
drect:=rect(drect.right,drect.Top,drect.right+round(0.29*(PageRect.Right-PageRect.Left)),srect.Bottom);
drawtext(pp_pz.Printer.Canvas.handle,pchar('摘 要'),length('摘 要'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
drect:=rect(drect.right,drect.Top,drect.right+round(0.16*(PageRect.Right-PageRect.Left)),srect.Bottom);
drawtext(pp_pz.Printer.Canvas.handle,pchar('借方金额'),length('借方金额'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
drect:=rect(drect.right,drect.Top,drect.right+round(0.16*(PageRect.Right-PageRect.Left)),srect.Bottom);
addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
drawtext(pp_pz.Printer.Canvas.handle,pchar('贷方金额'),length('贷方金额'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
drect:=rect(drect.right,drect.Top,drect.right+round(0.03*(PageRect.Right-PageRect.Left)),srect.Bottom);
addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]); jrect:=rect(drect.left,drect.Top+round((drect.bottom-drect.top-2*textheight)*0.5),drect.right,drect.Bottom);
drawtext(pp_pz.Printer.Canvas.handle,pchar('方向'),length('方向'),jrect,DT_center or DT_wordbreak); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
drect:=rect(drect.right,drect.Top,drect.right+round(0.18*(PageRect.Right-PageRect.Left)),srect.Bottom);
addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom,drect.left,drect.top]);
drawtext(pp_pz.Printer.Canvas.handle,pchar('期末余额'),length('期末余额'),drect,DT_center or DT_WORDBREAK or DT_VCENTER or DT_SINGLELINE); addpolyline([drect.left,drect.top,drect.right,drect.top,drect.right,drect.bottom,drect.left,drect.bottom]);
//
pp_pz.printer.Canvas.pen.Width:=4;
// pp_pz.printer.Canvas.pen.Style
PolyPolyline(pp_pz.Printer.Canvas.Handle,PolyPolyPoints.List^,PolyLengths.List^,PolyLengths.Count);----------------------------------------------------------
说明:楼上的,我不想换其他函数,因为我觉得PolyPolyline挺好的,就是怎么把线画粗来就行了!
replace with your PolyPolyline functions是指用你的PolyPolyline 来代替了我这一句试试看的意思.
1.你要用下面代码来新建一个宽为2的Pen.与你的输入设备相联接
PenPoint.x := 2; // 你想要的宽度.
PenPoint.y := 0;
Pen.lopnStyle := PS_SOLID;
Pen.lopnWidth := PenPoint;
Pen.lopnColor := clRed;
hPen := SelectObject(Dc,CreatePenIndirect(Pen)); // 邦定Pen到你的输出设备.
2. 直接用你的PolyPolyline函数来进行画多边形.
......
PolyPolyline(pp_pz.Printer.Canvas.Handle,PolyPolyPoints.List^,PolyLengths.List^,PolyLengths.Count);
3.画完或打印完后再还原以前的Pen.
SelectObject(DC, hPen);
procedure TForm1.Button1Click(Sender: TObject);
var
Dc : HDC;
Pt : Array [0..2] of TPoint ;
Count1, count2 : Integer;
Brush : TLogbrush;
hBrush,hPen : LongInt;
Pen : TLOGPEN;
PenPoint : TPoint;
dd : Integer;
begin
pt[0].x := 100;
pt[0].y := 100;
pt[1].x := 50;
pt[1].y := 150;
pt[2].x := 150;
pt[2].y := 150;
Dc := GetDC(handle);
Brush.lbStyle := BS_SOLID;
Brush.lbColor := clGreen;
Brush.lbHatch := 0;
hBrush := SelectObject(Dc,CreateBrushIndirect(Brush));
PenPoint.x := 10; // Your pen width here.
PenPoint.y := 0;
Pen.lopnStyle := PS_SOLID;
Pen.lopnWidth := PenPoint;
Pen.lopnColor := clRed;
hPen := SelectObject(Dc,CreatePenIndirect(Pen)); // bind your current canvas.
// Polygon(DC,pt,3); // replace with your PolyPolyline functions.
dd := 3;
PolyPolyline(DC,pt,dd, 3);
SelectObject(DC, hPen);
SelectObject(DC, hBrush);end;