施
施海鹏
Unregistered / Unconfirmed
GUEST, unregistred user!
我要实现的功能是:
控制阵式打印机,不让打印机一页一页地出纸。就是说,不管打印几条记录,都停在原位不动。
就好像商场里的收款机那样,逐行出纸。
以下是我的实现方法,我试了好几台打印机,都不行啊,总是整页出纸
function InitPrint: Boolean;
var
ADevice, ADriver, APort : array[0..255] of Char;
DeviceHandle : THandle;
DevMode: PDeviceMode;
SysLength, SysWidth: Integer;
begin
Result := False;
Printer.GetPrinter(Adevice, ADriver, Aport, DeviceHandle);
if DeviceHandle = 0 then
Exit;
try
DevMode := GlobalLock(DeviceHandle);
Except
GlobalUnLock(DeviceHandle);
GlobalFree(DeviceHandle);
end;
if DevMode <> nil then
begin
with DevMode^do
begin
dmFields := dmFields or DM_PAPERLENGTH;
SysLength := dmPaperLength;
dmFields := dmFields or DM_PAPERWIDTH;
SysWidth := dmPaperWidth;
end;
with DevMode^do
begin
dmFields := dmFields or DM_PAPERSIZE;
dmPaperSIZE := DMPAPER_USER;
dmFields := dmFields or DM_PAPERLENGTH;
dmPaperLength := 100;
//这里设置了页的长度
dmFields := dmFields or DM_PAPERWIDTH;
dmPaperWidth := SysWidth;
end;
Printer.Orientation := poPortrait;
ResetDC(Printer.Handle, DevMode^);
end;
GlobalUnLock(DeviceHandle);
Result := True;
end;
procedure PrintAlarm;
var
FPrn: System.Text;
{ 打印输出文件 }
begin
if not InitPrint then
Exit;
try
Assignprn(FPrn);
Rewrite(Fprn);
Write(FPrn, '各位大虾帮忙啊');
except
end;
System.CloseFile(FPrn);
end;
控制阵式打印机,不让打印机一页一页地出纸。就是说,不管打印几条记录,都停在原位不动。
就好像商场里的收款机那样,逐行出纸。
以下是我的实现方法,我试了好几台打印机,都不行啊,总是整页出纸
function InitPrint: Boolean;
var
ADevice, ADriver, APort : array[0..255] of Char;
DeviceHandle : THandle;
DevMode: PDeviceMode;
SysLength, SysWidth: Integer;
begin
Result := False;
Printer.GetPrinter(Adevice, ADriver, Aport, DeviceHandle);
if DeviceHandle = 0 then
Exit;
try
DevMode := GlobalLock(DeviceHandle);
Except
GlobalUnLock(DeviceHandle);
GlobalFree(DeviceHandle);
end;
if DevMode <> nil then
begin
with DevMode^do
begin
dmFields := dmFields or DM_PAPERLENGTH;
SysLength := dmPaperLength;
dmFields := dmFields or DM_PAPERWIDTH;
SysWidth := dmPaperWidth;
end;
with DevMode^do
begin
dmFields := dmFields or DM_PAPERSIZE;
dmPaperSIZE := DMPAPER_USER;
dmFields := dmFields or DM_PAPERLENGTH;
dmPaperLength := 100;
//这里设置了页的长度
dmFields := dmFields or DM_PAPERWIDTH;
dmPaperWidth := SysWidth;
end;
Printer.Orientation := poPortrait;
ResetDC(Printer.Handle, DevMode^);
end;
GlobalUnLock(DeviceHandle);
Result := True;
end;
procedure PrintAlarm;
var
FPrn: System.Text;
{ 打印输出文件 }
begin
if not InitPrint then
Exit;
try
Assignprn(FPrn);
Rewrite(Fprn);
Write(FPrn, '各位大虾帮忙啊');
except
end;
System.CloseFile(FPrn);
end;