Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer Select

Status
Not open for further replies.

cwolgamott

Programmer
May 29, 2002
69
US
Hello. :) How can you allow the user to select which printer that they want to print to in Delphi 6 when trying to print a crystal report?
 
I wrote this combo box component that will give the user a drop-down list of all available printers. When the user selects the printer, it becomes the current printer. i used it in a Crystal Reports viewer program:

unit PrintersCombo;

interface

uses
Windows, Messages, SysUtils, Classes, Printers,Graphics, Controls, Forms, Dialogs,
StdCtrls;

type

TPrintersCombo = class(TComboBox)
private

protected
procedure Click;override;
procedure CreateWnd; override;
public
CurrentPrinter:string;
constructor Create(AOwner: TComponent);override;
published
{ Published declarations }
property Style default csDropDown;
property Items stored False;

end;

procedure Register;

implementation


procedure Register;
begin
RegisterComponents('Samples', [TPrintersCombo]);
end;

{ TPrintersCombo }


procedure TPrintersCombo.Click;
var
index:integer;
begin
inherited Click;
index:=0;
CurrentPrinter:=Text;
index:=Printer.Printers.IndexOf(CurrentPrinter);
Printer.PrinterIndex:=index;
end;

constructor TPrintersCombo.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Printer.PrinterIndex:=-1;
CurrentPrinter:=Printer.Printers[Printer.PrinterIndex];
Text:=CurrentPrinter;
Style:=csDropDown;
Width:=250;
Update;
end;

procedure TPrintersCombo.CreateWnd;
begin
inherited CreateWnd;
Items.Assign(Printer.Printers);
end;


end.
 
Thank you so much for your response. :) I really appreciate it. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top