1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131:
| var x,y,li,ob,re,un,waag,senk,a:integer; fix,grund,schrift:TColor; r:Trect; function rech(i,j:integer):integer; begin result:=round(((i*j) / 72) * scal); end;
begin if vZeile < 0 then vZeile:=0; if vSpalte < 0 then vSpalte:=0; if (bZeile >= grd.rowcount)or(bZeile < 0) then bZeile:=grd.rowcount - 1; if (bSpalte >= grd.colcount)or(bSpalte < 0) then bSpalte:=grd.colcount - 1; if vZeile > bZeile then begin a:=vZeile;vZeile:=bZeile;bZeile:=a; end; if vSpalte > bSpalte then begin a:=vSpalte;vSpalte:=bSpalte;bSpalte:=a; end;
if (scal > 0)and(vZeile < grd.rowcount)and(vSpalte < grd.colcount) then begin if farbig then begin fix:=grd.fixedcolor; grund:=grd.color; schrift:=grd.font.color; end else begin fix:=clsilver; grund:=clwhite; schrift:=clblack; end; waag:=getdevicecaps(printer.handle,logpixelsx); senk:=getdevicecaps(printer.handle,logpixelsy); links:=rech(links,waag); oben:=rech(oben, senk); li:=getdevicecaps(printer.handle,physicaloffsetx)+1+links; a:=rech(3,waag); with printer do begin title:='Grid-Druck'; BeginDoc; if grd.gridlinewidth > 0 then begin canvas.pen.color:=$333333; canvas.pen.width:=1; canvas.pen.style:=pssolid end else canvas.pen.style:=psclear; canvas.font:=grd.font; canvas.font.color:=schrift; canvas.font.size:=round((grd.font.size / 0.72) * scal); for x:=vSpalte to bSpalte do begin ob:=getdevicecaps(printer.handle,physicaloffsety)+1+oben; re:=li+rech(grd.ColWidths[x]+1,waag); for y:=vZeile to bZeile do begin un:=ob+rech(grd.RowHeights[y]+1,senk); if (x < grd.fixedcols)or(y < grd.fixedrows) then canvas.brush.color:=fix else canvas.brush.color:=grund; canvas.rectangle(li,ob,re+2,un+2); r:=rect(li+a,ob+1,re-a,un-2); drawtext(canvas.handle,pchar(grd.Cells[x,y]),length(grd.Cells[x,y]), r,DT_SINGLELINE or DT_VCENTER); ob:=un; end; li:=re; end; enddoc; end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin griddruck(stringgrid1,0,0,-1,-1,-1,-1,1,true); end; procedure TForm1.Button2Click(Sender: TObject); begin griddruck(stringgrid1,stringgrid1.left,stringgrid1.top,0,2,0,2,1,true); end; procedure TForm1.Button1Click(Sender: TObject); begin griddruck(stringgrid1,0,0,0,0,-1,-1,0.5,false); end; procedure TForm1.Button1Click(Sender: TObject); var s,z:integer; begin s:=stringgrid1.ColCount-1; z:=stringgrid1.RowCount-1; griddruck(stringgrid1,25,30,0,s div 2,0,z div 2,1,true); griddruck(stringgrid1,25,30,s div 2 + 1,s,0,z div 2,1,true); griddruck(stringgrid1,25,30,0,s div 2,z div 2 + 1,z,1,true); griddruck(stringgrid1,25,30,s div 2 + 1,s,z div 2 + 1,z,1,true); end; |