DELPHI5中在WIN2000(NT)中使用自定义纸张(21*14)cm.
在DELPHI5中使用CUSTOM(自定义)纸张,QP5中
在WIN2000中选择打印机->服务器属性->新建一种纸张(21*14)cm,
取名CUSTOM SIZE ->在打印机高级选项中选择这种纸.

解决方案 »

  1.   

    用DevMode字段可以!
     如设置纸的Width:
    procedure TPrintForm.SetWidth(PaperWidth: longint);
    var
      ADevice, ADriver, APort: String;
      ADeviceMode: THandle;
      DevMode: PDeviceMode;
    begin
     SetLength(ADevice, 255);
     SetLength(ADriver, 255);
     SetLength(APort, 255); { If ADeviceMode is zero, a printer driver is not loaded. Therefore,
       setting PrinterIndex forces the driver to load. }
     if ADeviceMode = 0 then
     begin
       Printer.PrinterIndex := Printer.PrinterIndex;
       Printer.GetPrinter(PChar(ADevice), PChar(ADriver), PChar(APort), ADeviceMode);
     end; if ADeviceMode <> 0 then
     begin
       DevMode := GlobalLock(ADeviceMode);
       try
         DevMode^.dmFields := DevMode^.dmFields or DM_PAPERWIDTH; //or DM_PAPERWIDTH; DevMode^.dmPaperLength := PaperLength;
         DevMode^.dmPaperWidth := PaperWidth;
         ///////////////////////设置纸张////////////////
       finally
         GlobalUnlock(ADeviceMode);
       end;
     end
     else
       raise Exception.Create('Could not set printer copies');
    end;