运行出错(50分)

  • 主题发起人 主题发起人 ych2071
  • 开始时间 开始时间
Y

ych2071

Unregistered / Unconfirmed
GUEST, unregistred user!
type
PDevMode=^TDevMode;
TPrinterDev = class
Driver: string;
Device: string;
Port: string;
end;


implimentation

procedure TForm1.SetPrinter;
var
Devs: PDevMode;
DevsP: Pointer;
DevSize: integer;
PrinterObject: THandle;
DevName: string;
begin

PrinterObject:= Printer.Handle;
DevName:= TPrinterDev(Printer.Printers.Objects[Printer.PrinterIndex]).Device;
DevSize:=DocumentProperties(0,PrinterObject,PChar(DevName),Devs,Devs,0);
DevsP:=AllocMem(DevSize);
try
do
cumentProperties(0,PrinterObject,Pchar(DevName),nil,DevsP,DM_OUT_BUFFER);
Devs:=DevsP;
Devs^.dmFields:=DM_PAPERSIZE;
Devs^.dmPaperSize:=DMPAPER_FANFOLD_US;

// if use USER_DEFINE paper then

// this line change to
// Devs^.dmFields:= DM_PAPERSIZE or DM_PAPERLENGTH or DM_PAPERWIDTH;
// Devs^.dmPaperSize:=0;
// Devs^.dmPaperLength:= ur defined paper length value;
// Devs^.dmPaperWidth:= ur defined paper width value;
do
cumentProperties(0,PrinterObject,Pchar(DevName),DevsP,DevsP,DM_OUT_BUFFER or DM_IN_BUFFER);
finally
FreeMem(DevsP,DevSize);
end;

end;


end.

运行出错,incopatible types:"_devicemodeA " with "pointer"
在语句:documentproperties上
 
看大家的意思是:
用quickrep无法打印自定义的纸张!
(在程序中设置,而非手动设置).
难道没有办法吗?
 
看DELPHI申明的原型:

functiondo
cumentProperties(hWnd: HWND;
hPrinter: THandle;
pDeviceName: PChar;
const pDevModeOutput: TDeviceMode;
var pDevModeInput: TDeviceMode;
fMode: DWORD): Longint;
stdcall;

应该是TDeviceMode 不是PDeviceMode
 
怎么改正?
详细点,好吗?
 
到底有没有一种方法在程序中设置打印机的自定义模式?(quickreport 实现报表)
 
接受答案了.
 
后退
顶部