你用QUICKREPORT不就行了?你用PrinterDialog也可以进行设置呀.
我这儿有一段设置纸张大小的代码,是从别人那儿抄来的.忘了是谁的了.如下:
unit uPrintPaperSetup;
interface
uses windows,printers,SysUtils;
procedure SetPaperSize(X, Y: Integer);
function TransformX(X: Integer): Integer;
function TransformY(Y: Integer): Integer;
function InitPrinter: Boolean;
implementation
var
RateX, RateY: Integer;
function InitPrinter: Boolean;
begin
Result := Printer.Printers.Count > 0;
RateX := MulDiv(GetDeviceCaps(Printer.Handle, LOGPIXELSX), 1000, 254);
RateY := MulDiv(GetDeviceCaps(Printer.Handle, LOGPIXELSY), 1000, 254);
end;
procedure SetPaperSize(X, Y: Integer);
var
Device, Driver, Port: PChar;
HDMode: THandle;
PDMode: PDevMode;
begin
Device := StrAlloc(cchDeviceName);
Driver := StrAlloc(MAX_PATH);
Port := StrAlloc(32);
try
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, HDMode);
if HDMode <> 0 then
begin
PDMode := GlobalLock(HDMode);
if PDMode <> nil then
begin
with PDMode^do
begin
dmPaperSize := 256;
dmPaperWidth := X;
dmPaperLength := Y;
dmFields := dmFields or DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
GlobalUnlock(HDMode);
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;
end;
finally
StrDispose(Device);
StrDispose(Driver);
StrDispose(Port);
end;
end;
function TransformX(X: Integer): Integer;
begin
Result := MulDiv(X, RateX, 1000);
end;
function TransformY(Y: Integer): Integer;
begin
Result := MulDiv(Y, RateY, 1000);
end;
procedure TransformPoint(Point: TPoint);
begin
Point.x := TransformX(Point.x);
Point.y := TransformY(Point.y);
end;
procedure TransformRect(Rect: TRect);
begin
Rect.Left := TransformX(Rect.Left);
Rect.Right := TransformX(Rect.Right);
Rect.Top := TransformY(Rect.Top);
Rect.Bottom := TransformY(Rect.Bottom);
end;
end.
调用:
uses uPrintPaperSetup;
if not InitPrinter then
Application.MessageBox('', '', mb_IconError + mb_OK)
else
SetPaperSize(800, 800);//设定纸张为8厘米,这儿的精度是0.1mm.