Ver Mensaje Individual
  #7  
Antiguo 11-01-2008
Avatar de Delphius
[Delphius] Delphius is offline
Miembro Premium
 
Registrado: jul 2004
Ubicación: Salta, Argentina
Posts: 5.582
Reputación: 25
Delphius Va camino a la fama
Hola ldmar3,
No tengo Delphi a mano...
Espero poder expresarme bien.

Printer mantiene un listado de todas la impresoras instaladas en el equipo (para ello la propiedad Printers). El procedimiento recibe como parámetro el Nombre de la impresora a seleccionar. Y lo que realiza es buscarla dentro de dicha lista... Si la encuentra (Index <> -1) la asocia como predeterminada mediante la propiedad PrinterIndex.

Te recomendaría que leas la ayuda sobre la clase TPrinter.

EDITO:
Está hecha al vuelo... asi que no te garantizo si andará... creería que esto puede darte una idea de como funciona:

Código Delphi [-]
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure SeleccionarImpresora(Nombre: string);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
  for i := 0 to Printer.Printers.Count - 1 do
    ListBox1.Items.Add(Printer.Printers[i]);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SeleccionarImpresora(Edit1.Text);
end;

procedure TForm1.SeleccionarImpresora(Nombre: string);
var Index: integer;
begin
  Index := Printer.Printers.IndexOf(Nombre);
  if Index <> -1
     then begin
            Printer.PrinterIndex := Index;
            ListBox1.Selected[Index] := True;
          end;
end;

end.

Saludos,
__________________
Delphius
[Guia de estilo][Buscar]

Última edición por Delphius fecha: 11-01-2008 a las 03:29:41.
Responder Con Cita