LQ1600K打印机,连续纸,用QReport打印报表,各个报表的大小不一样,每次打印前要手工修改自定义纸张的大小,否则打出来换页位置不对。请问,如何在程序中修改打印机的自定义纸张大小?

解决方案 »

  1.   

    var
        ADevice,ADriver,Aport : Array [0..255] of char;
        DeviceHandle: THandle;
        DevMode: PDeviceMode;
        ps: integer;// pagesize;
        po: integer;//Orientation
    begin   case combobox1.ItemIndex of
         0:  ps:= DMPAPER_A3;
         1:  ps:= DMPAPER_A4;
         2:  ps:= DMPAPER_B4;
         3:  ps:= DMPAPER_B5;
       end;
       if RadioButton2.Checked then
          po:= DMORIENT_PORTRAIT else
          po:= DMORIENT_LANDSCAPE;   printer.GetPrinter(ADevice,ADriver,APort,DeviceHandle);
       if DeviceHandle = 0 then
       begin
          Printer.PrinterIndex := Printer.PrinterIndex + 1;
          printer.GetPrinter(ADevice,ADriver,APort,DeviceHandle);
       end;
       if DeviceHandle = 0 then
       begin
          application.MessageBox('没有发现打印机','错误',MB_OK+MB_ICONERROR);
          exit;
       end;
       DevMode:= GlobalLock(DeviceHandle);
       DevMode.dmFields:= DevMode.dmFields or DM_PAPERSIZE;
       DevMode.dmPaperSize := ps;
       DevMode.dmFields:= DevMode.dmFields or DM_ORIENTATION;
       DevMode.dmOrientation := po;   GlobalUnLock(DeviceHandle);
       
       self.ModalResult := mrok;
    end;
      

  2.   

    谢了,我先试一下,然后给分。我还在 http://expert.csdn.net/Expert/topic/1998/1998083.xml?temp=.9230463 提了个相同的问题,没人回答,你去up一下,分一并给你。