Ver la Versión Completa : QRPrintSetup actualizar impresora seleccionada
jonydread
11-06-2013, 06:05:18
Buenas noches desde aca, les cuento tengo un quickrep, con una preview personalizada esta agrege botones con una coolbar, al boton imprimir le puse el sgte codigo y si cambio la impresora le da igual siempre me tira la impresion a la misma impresora, aca (http://www.clubdelphi.com/foros/showthread.php?t=71442)en el foro hay temas sobre esto pero no encontre una solucion
procedure TPreview.ToolButton1Click(Sender: TObject);
begin
reporteform.quickrep1.QRPrinter.PrintSetup;
if reporteform.quickrep1.QRPrinter.Master.tag = 0 then
reporteform.quickrep1.QRPrinter.Print;
end;
adjunto custompreview.pas
saludos
marcoszorrilla
11-06-2013, 07:26:07
Yo hago esto:
procedure TfrConclientes.SpeedButton4Click(Sender: TObject);
begin
Application.CreateForm(TfrlstClientes, frlstClientes);
frlstClientes.ListaClientes.PrinterSettings.PrinterIndex:=GetImpresora(Impresora4);
frlstClientes.ListaClientes.Print;
frlstClientes.Close;
end;
Un Saludo
marcoszorrilla
11-06-2013, 07:28:48
Añado la función que selecciona la impresora, por ejemplo la que este configuradad para Facturas, Pedidos, Listados...
Function GetImpresora(Impre:String):Integer;
Var
nCont:Integer;
lSearch:Boolean;
cNewLIne:String;
begin
lSearch:=False;
cNewLine:=Chr(10)+Chr(13);
For nCont:=0 to Printer.Printers.Count - 1 do
//buscamos la impresora en la lista del sistema
begin
if Pos(impre, Printer.Printers[nCont]) <> 0 then
begin
lSearch:=True;
Result:=nCont;
Break;
end;
end;
if lSearch = False then
begin
ShowMessage('Impresora no encontrada.'+impre+cNewLine+'Se utilizará la predeterminda.');
Result:=-1
end;
end;
Un Saludo.
jonydread
12-06-2013, 07:13:55
lo realizo asi y dice GetImpresora undeclared identifier
en el quickrep
procedure TReporteForm.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
QuickRep1.PrinterSettings.Printerindex:=GetImpresora(qrPrinter.PrinterIndex);
end;
Function GetImpresora(Impre:String):Integer;
Var
nCont:Integer;
lSearch:Boolean;
cNewLIne:String;
begin
lSearch:=False;
cNewLine:=Chr(10)+Chr(13);
For nCont:=0 to Printer.Printers.Count - 1 do
//buscamos la impresora en la lista del sistema
begin
if Pos(impre, Printer.Printers[nCont]) <> 0 then
begin
lSearch:=True;
Result:=nCont;
Break;
end;
end;
if lSearch = False then
begin
ShowMessage('Impresora no encontrada.'+impre+cNewLine+'Se utilizará la predeterminda.');
Result:=-1
end;
end;
en boton del QRPreview
procedure TPreview.ToolButton1Click(Sender: TObject);
begin
reporteform.quickrep1.QRPrinter.PrintSetup;
if reporteform.quickrep1.QRPrinter.Master.tag = 0 then
reporteform.quickrep1.QRPrinter.Print;
end;
que hago mal??
ecfisa
12-06-2013, 16:34:50
lo realizo asi y dice GetImpresora undeclared identifier
...
que hago mal??
Hola jonydread.
Function GetImpresora(Impre:String):Integer;
Var
nCont:Integer;
lSearch:Boolean;
cNewLIne:String;
begin
lSearch:=False;
cNewLine:=Chr(10)+Chr(13);
For nCont:=0 to Printer.Printers.Count - 1 do
//buscamos la impresora en la lista del sistema
begin
if Pos(impre, Printer.Printers[nCont]) <> 0 then
begin
lSearch:=True;
Result:=nCont;
Break;
end;
end;
if lSearch = False then
begin
ShowMessage('Impresora no encontrada.'+impre+cNewLine+'Se utilizará la predeterminda.');
Result:=-1
end;
end;
procedure TReporteForm.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
QuickRep1.PrinterSettings.Printerindex:=GetImpresora(qrPrinter.PrinterIndex);
end;
GetImpresora es una función y a diferencia de un método, su declaración tiene que preceder en órden al código que la invoca.
Saludos. :)
jonydread
13-06-2013, 05:10:59
creo que el problema esta en
GetImpresora(QRPrinter.PrinterIndex)
no se puede utilizar QRPrinter.PrinterIndex y dice Returnvalue of function GetImpresora migth be undefined si dejo vacio para probar el error y es lo mismo
como puedo obtener la impresora seleccionada en el printsetup qe esta en preview del quickrep
reporteform.quickrep1.QRPrinter.PrintSetup
jonydread
13-06-2013, 06:48:38
he quitado el error pero no obtener la impresora seleccionada :confused:
procedure TPreview.ToolButton1Click(Sender: TObject);
var
simp:string;
begin
ReporteForm.quickrep1.QRPrinter.printsetup;
if ReporteForm.quickrep1.QRPrinter.Master.tag = 0 then
begin
simp := inttostr(ReporteForm.quickrep1.QRPrinter.PrinterIndex);
ReporteForm.quickrep1.PrinterSettings.PrinterIndex:=GetImpresora(simp);
showmessage(simp);
ReporteForm.quickrep1.QRPrinter.Print;
end;
end;
ecfisa
13-06-2013, 08:31:10
como puedo obtener la impresora seleccionada en el printsetup qe esta en preview del quickrep
Hola jonydread.
Para obtener la impresora actualmente seleccionada te tendría que alcanzar con:
...
implementation
uses Printers;
function GetCurrentPrinterName: string;
begin
Result := '';
if Printer.PrinterIndex <> -1 then
Result := Printer.Printers[Printer.PrinterIndex];
end;
...
Pero en estos enlaces vas a encontrar mas opciones, tanto para obtenerla como para configurarla:
Get Default Printer Name (http://delphi.about.com/cs/adptips2001/a/bltip0901_4.htm)
...get / set the default printer? (http://www.swissdelphicenter.ch/torry/showcode.php?id=660)
How to change the default printer from Delphi (http://edn.embarcadero.com/article/28936)
Saludos. :)
jonydread
14-06-2013, 05:17:42
Muchas gracias Ecfisa y tambien a marcoszorrilla
finalmente lo logre!! #:-)#v:-)v
quedo asi
Function GetImpresora(Impre:String):Integer;
Var
nCont:Integer;
lSearch:Boolean;
cNewLIne:String;
begin
lSearch:=False;
cNewLine:=Chr(10)+Chr(13);
For nCont:=0 to Printer.Printers.Count - 1 do
//buscamos la impresora en la lista del sistema
begin
if Pos(impre, Printer.Printers[nCont]) <> 0 then
begin
lSearch:=True;
Result:=nCont;
Break;
end;
end;
if lSearch = False then
begin
ShowMessage('Impresora no encontrada.'+impre+cNewLine+'Se utilizará la predeterminda.');
Result:=-1
end;
end;
function GetCurrentPrinterName: string;
begin
Result := '';
if Printer.PrinterIndex <> -1 then
Result := Printer.Printers[Printer.PrinterIndex];
end;
procedure TPreview.ToolButton1Click(Sender: TObject);
var
simp:string;
begin
ReporteForm.quickrep1.QRPrinter.printsetup;
if ReporteForm.quickrep1.QRPrinter.Master.tag = 0 then
begin
simp := GetCurrentPrinterName;
ReporteForm.QuickRep1.QRPrinter.PrinterIndex := getimpresora(simp);
ReporteForm.quickrep1.QRPrinter.Print;
end;
end;
vBulletin v3.6.8, Derechos ©2000-2024, Jelsoft Enterprises Ltd.