系统中装有多台打印机如何在用quickrep做报表时根据情况选择想要得打印机?

解决方案 »

  1.   

    设置默认打印机应该可以吧,如果不行可以先预览,后选择
    哈哈,这样比较麻烦,但也是一种方法
    我没用过QUICKREP,胡诌的
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Device: array[0..255] of Char;
      Driver: array[0..255] of char;
      Port: array[0..255] of char;
      s : array[0..255] of Char;
      hDeviceMode: THandle;begin
      //messagebeep(2);
      beep();
      Printer.PrinterIndex := ComboBox1.ItemIndex;
      Printer.GetPrinter (Device, Driver, Port, hDeviceMode);
      StrCopy (s, Device);
      StrCat (s, ',');
      StrCat (s, Driver);
      StrCat (s, ',');
      StrCat (s, Port);
      WriteProfileString ('windows', 'device', s);
      StrCopy (s, 'windows');
      SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s));
      ComboBox1.Items := Printer.Printers; {populates ComboBox}
      ComboBox1.ItemIndex := Printer.PrinterIndex; 
    end;procedure TForm1.ComboBox1Change(Sender: TObject);
    var
      Device: array[0..255] of Char;
      Driver: array[0..255] of char;
      Port: array[0..255] of char;
      s : array[0..255] of Char;
      hDeviceMode: THandle;begin  Printer.PrinterIndex := ComboBox1.ItemIndex;
      Printer.GetPrinter (Device, Driver, Port, hDeviceMode);
      StrCopy (s, Device);
      StrCat (s, ',');
      StrCat (s, Driver);
      StrCat (s, ',');
      StrCat (s, Port);
      WriteProfileString ('windows', 'device', s);
      StrCopy (s, 'windows');
      SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s));
    end;
    以上为改变默认打印机代码
      

  3.   

    我想在用quickrep时改变。
    察看帮助如下:
    QuickRep1.QrPrinter.PrinterIndex:=-1;//默认打印机;
    但是就是这一句总是出地址错误,不知道什魔原因