如何利用printdialog,把选好的打印机作为quickreport的默认打印机?谢谢。

解决方案 »

  1.   

    printdialog我很少用,我一般用RB
      

  2.   

    使用QR的时候,如果系统有多台打印机,如果要使用某台指定的打印机的话,QR却把所有的打印人物都发送到默认的打印机上面去了,那么如何发送到指定的打印机呢?可以这样,直接指定输出打印机就可以了:Printer.PrinterIndex:=0; ///指定第一台打印机为输出设备Printer.PinnterIndex:=-1; ///默认打印机为输出设备
      

  3.   

    我不想这样设置,我想在printdialog中设好后,以后打印QR就直接用它。我是想让用户灵活设置。
      

  4.   

    做个FORM(打印机选择) 设个参数(或把参数记录下来),以后动态调用不就行了。用户要设置时打开FORM再选择一次。
      

  5.   

    动态选择默认打印机:
    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;