心
心心
Unregistered / Unconfirmed
GUEST, unregistred user!
有一列代码如下,但设置后在1600K中能正常设置在BJC4550、4650均还是A4纸型谁能帮我?
if (OptionForm.Edit1.Text <> '') and (OptionForm.Edit2.Text <> '') then
begin
CustomLength := StrToInt(OptionForm.Edit1.Text);
CustomWidth := StrToInt(OptionForm.Edit2.Text);
end;
PointX := Trunc(GetDeviceCaps(Printer.Handle, LogpixelsX) / 2.54);
PointY := Trunc(GetDeviceCaps(Printer.Handle, LogpixelsY) / 2.54);
PointScale := Trunc(GetDeviceCaps(Printer.Handle, LogpixelsX) / Screen.PixelSperInch + 0.18);
//以下设置打印机纸张类型
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
if (CustomLength = 0) or (CustomWidth = 0) then
begin
{Set to legal}
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
{pDMode^.dmPaperSize := DMPAPER_LEGAL;
changed by wulianmin}
pDMode^.dmPaperSize := DMPAPER_FANFOLD_US;
end
else
begin
{Set to custom size}
pDMode^.dmFields := pDMode^.dmFields or
DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperWidth := CustomLength {SomeValueInTenthsOfA Millimeter};
pDMode^.dmPaperLength := CustomWidth {Some Value In Ten ths Of AMillimeter};
end;
{Set the bin to use}
pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
pDMode^.dmDefaultSource := DMBIN_MANUAL;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
//设置打印机打印方向
if OptionForm.radioGroup1.ItemIndex = 0 then
Printer.Orientation := poLandscape
else
Printer.Orientation := poPortrait;
if Trim(HandTitle) = '' then
HandTitle := '电脑';
PrintStep := Printer.Canvas.TextHeight(HandTitle) + 16;
X := PointX * LeftBlank;
Y := PointY * TopBlank;
Printer.Title := Title1;
//求出表格总长
for I := 0 to GridTmp.Colcount - 1do
Xtmp := Xtmp + GridTmp.ColWidths * PointScale;
//XBL为缩放比率
XBL1 := ROUND((1 - (XTMP - Printer.PageWidth) / XTmp) * 5000);
//以下开始打印
Printer.begin
Doc;
if (OptionForm.Edit1.Text <> '') and (OptionForm.Edit2.Text <> '') then
begin
CustomLength := StrToInt(OptionForm.Edit1.Text);
CustomWidth := StrToInt(OptionForm.Edit2.Text);
end;
PointX := Trunc(GetDeviceCaps(Printer.Handle, LogpixelsX) / 2.54);
PointY := Trunc(GetDeviceCaps(Printer.Handle, LogpixelsY) / 2.54);
PointScale := Trunc(GetDeviceCaps(Printer.Handle, LogpixelsX) / Screen.PixelSperInch + 0.18);
//以下设置打印机纸张类型
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
if (CustomLength = 0) or (CustomWidth = 0) then
begin
{Set to legal}
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
{pDMode^.dmPaperSize := DMPAPER_LEGAL;
changed by wulianmin}
pDMode^.dmPaperSize := DMPAPER_FANFOLD_US;
end
else
begin
{Set to custom size}
pDMode^.dmFields := pDMode^.dmFields or
DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperWidth := CustomLength {SomeValueInTenthsOfA Millimeter};
pDMode^.dmPaperLength := CustomWidth {Some Value In Ten ths Of AMillimeter};
end;
{Set the bin to use}
pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
pDMode^.dmDefaultSource := DMBIN_MANUAL;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
//设置打印机打印方向
if OptionForm.radioGroup1.ItemIndex = 0 then
Printer.Orientation := poLandscape
else
Printer.Orientation := poPortrait;
if Trim(HandTitle) = '' then
HandTitle := '电脑';
PrintStep := Printer.Canvas.TextHeight(HandTitle) + 16;
X := PointX * LeftBlank;
Y := PointY * TopBlank;
Printer.Title := Title1;
//求出表格总长
for I := 0 to GridTmp.Colcount - 1do
Xtmp := Xtmp + GridTmp.ColWidths * PointScale;
//XBL为缩放比率
XBL1 := ROUND((1 - (XTMP - Printer.PageWidth) / XTmp) * 5000);
//以下开始打印
Printer.begin
Doc;