Ver Mensaje Individual
  #14  
Antiguo 30-09-2004
Avatar de yusnerqui
yusnerqui yusnerqui is offline
Miembro
 
Registrado: mar 2004
Ubicación: Cuba
Posts: 679
Reputación: 21
yusnerqui Va por buen camino
Mucha gracias

Muchas gracias Lepe, poco después de postear encontré la solución. A propósito a continuación vioy a mostrar lo que hago para configurar la página del reporte en tiempo de ejecución, me funciona bien en Windows 98 no lo he probado en otros sistemas operativos
Código Delphi [-]
  procedure TReport.Vistaprevia;
var
  Title:string;
  I : Integer;
begin
  Previ := TPrevi.Create(Self);
 //Creo el pQuickreport y cambio sus propiedades a gusto del usuario!!
  Previ.pQuickreport := TQuickRep.Create(Previ); 
  with Previ.pQuickreport do
  begin
    Page.Units :=  MM;
    Page.PaperSize := Custom;
    Page.Width  := 420.0;//Puede ser un valor definido por el usuario
    Page.Length := 270.0;//   "                                    "
  end;

  
  Title:=Edit1.Text;

 try
   if Campos1.items.Count >0 then
   begin
     QRCreatelist(TCustomQuickRep(Previ.pQuickreport),Previ,RTabla,Title,Campos1.Items);
    try
      with Previ.pQuickreport do
      begin
       with Bands.ColumnHeaderBand  do
       begin
         Font.Size := 12;
         Font.Style:= [fsBold];
         Frame.DrawBottom := True;
         for i := 0 to ControlCount -1 do
           if Controls[i] is TQRLabel then
             TQRLabel(Controls[i]).Frame.DrawBottom := False;
       end;
       with Bands.DetailBand do
       begin
         Font.Size := 12;
         //aquí capturo los campos boolean para redireccionar su evento 
         //onPrint y no me imprima True y False sino los caracteres que yo 
        //espesifique
         for i := 0 to ControlCount -1 do
           if Controls[i] is TQRExpr then
           begin
             Title := TQRExpr(Controls[i]).Expression;
             Title := Copy(Title,2,Length(Title)-2);
             if ord(RTabla.FieldByName(Title).DataType) = 5 then
             begin
               TQRExpr(Controls[i]).Alignment := taCenter;
               TQRExpr(Controls[i]).OnPrint:= MyOnPrint;
             end;
           end;
       end;
         Previ.pQuickreport.OnPreview:= MyPreview;
         Previ.pQuickreport.Preview;
      end;
    finally
      //
    end;
  end;
 finally
 //
 end ;

Este código está en fase de depuración, ahora la impementación de MyPreview

Código Delphi [-]
procedure TReport.MyPreview(Sender : TObject);
begin
  with Previ do
  begin
    Preview.QRPrinter := TQRPrinter(Sender);
    Show;
  end;
end;

Por último, no me preocupo por el ancho de las columnas pues lo primero que hago es mostrar los campos seleccionados en un DBgrid donde el usuario puede ajustar el ancho de cada campo a su antojo
y es todo, espero que a alguien le sirva si lo que quiere es configurar página, márgenes etc les ser virá esta idea.

Un saludo
__________________
Lo importante no es llegar primero, sino saber llegar.

Para que puedas llegar mejor lee la Guia de Estilo

Responder Con Cita