H
huhongru
Unregistered / Unconfirmed
GUEST, unregistred user!
如题:
我在本地的打印机上可以用以下的函数创建创建用户自定义的打印的格式,但是我如果在网络打印机上创建用户自定义的打印的格式呢!
很奇怪,只在我在本机器上安装了网络打印机,本地也不能创建用户自定义的打印格式!
function TFrmPrt.AddCustomPaperSize(pFormName: PChar;
nPaperWidth, nPaperLength: Longint): Longint;
var
phPrinter, dwNeeded, dwReturned, i: LongWord;
pBuf: PChar;
pFormInfo: PFormInfo1A;
hDMode : THandle;
hPrinter : THandle;
PrintDevice, PrintDriver, PrintPort : array[0..255] of Char;
begin
Result := -1;
if OpenPrinter(PChar(Printer.Printers[0]), phPrinter, nil) then
begin
EnumForms(phPrinter, 1, nil, 0, dwNeeded, dwReturned);
pBuf := AllocMem(dwNeeded);
EnumForms(phPrinter, 1, pBuf, dwNeeded, dwNeeded, dwReturned);
for i := 0 to dwReturned - 1do
if PFormInfo1A(pBuf + i*SizeOf(_FORM_INFO_1A)).pName = String(pFormName) then
begin
Result := i;
Break;
end;
FreeMem(pBuf);
if Result < 0 then
begin
New(pFormInfo);
with pFormInfo^do
begin
Flags := FORM_USER;
pName := pFormName;
Size.cx := 1000;
Size.cy := 1000;
ImageableArea.Left := 1000;
ImageableArea.Top := 1000 ;
ImageableArea.Right := nPaperWidth;
//不可修改 ,如果修改了则创建不出新的打印格式
ImageableArea.Bottom := nPaperLength;
//不可修改 ,如果修改了则创建不出 新的打印格式
end;
AddForm(phPrinter, 1, pFormInfo);
Dispose(pFormInfo);
Result := dwReturned;
end;
end;
ClosePrinter(phPrinter);
end;
我在本地的打印机上可以用以下的函数创建创建用户自定义的打印的格式,但是我如果在网络打印机上创建用户自定义的打印的格式呢!
很奇怪,只在我在本机器上安装了网络打印机,本地也不能创建用户自定义的打印格式!
function TFrmPrt.AddCustomPaperSize(pFormName: PChar;
nPaperWidth, nPaperLength: Longint): Longint;
var
phPrinter, dwNeeded, dwReturned, i: LongWord;
pBuf: PChar;
pFormInfo: PFormInfo1A;
hDMode : THandle;
hPrinter : THandle;
PrintDevice, PrintDriver, PrintPort : array[0..255] of Char;
begin
Result := -1;
if OpenPrinter(PChar(Printer.Printers[0]), phPrinter, nil) then
begin
EnumForms(phPrinter, 1, nil, 0, dwNeeded, dwReturned);
pBuf := AllocMem(dwNeeded);
EnumForms(phPrinter, 1, pBuf, dwNeeded, dwNeeded, dwReturned);
for i := 0 to dwReturned - 1do
if PFormInfo1A(pBuf + i*SizeOf(_FORM_INFO_1A)).pName = String(pFormName) then
begin
Result := i;
Break;
end;
FreeMem(pBuf);
if Result < 0 then
begin
New(pFormInfo);
with pFormInfo^do
begin
Flags := FORM_USER;
pName := pFormName;
Size.cx := 1000;
Size.cy := 1000;
ImageableArea.Left := 1000;
ImageableArea.Top := 1000 ;
ImageableArea.Right := nPaperWidth;
//不可修改 ,如果修改了则创建不出新的打印格式
ImageableArea.Bottom := nPaperLength;
//不可修改 ,如果修改了则创建不出 新的打印格式
end;
AddForm(phPrinter, 1, pFormInfo);
Dispose(pFormInfo);
Result := dwReturned;
end;
end;
ClosePrinter(phPrinter);
end;