Link to home
Start Free TrialLog in
Avatar of jlislo
jlislo

asked on

Disable quick report preview save/load button

Hi,

I need to know how to disable quick report save/load button in preview mode.

Thanks.

JL
Avatar of DragonSlayer
DragonSlayer
Flag of Malaysia image

Create your own preview, here's a quick example:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  QRPrntr, ExtCtrls, QuickRpt, Db, DBTables, ComCtrls, ToolWin, Qrctrls,
  StdCtrls, ActnList, Spin;

type
  TForm1 = class(TForm)
    QuickRep1: TQuickRep;
    QRPreview1: TQRPreview;
    Table1: TTable;
    DetailBand1: TQRBand;
    QRDBText1: TQRDBText;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ActionList1: TActionList;
    actPrevPage: TAction;
    actNextPage: TAction;
    SpinEdit1: TSpinEdit;
    procedure QuickRep1Preview(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure actPrevPageUpdate(Sender: TObject);
    procedure actPrevPageExecute(Sender: TObject);
    procedure actNextPageUpdate(Sender: TObject);
    procedure actNextPageExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.QuickRep1Preview(Sender: TObject);
begin
  QRPreview1.QRPrinter := TQRPrinter(Sender);
end;

procedure TForm1.ToolButton1Click(Sender: TObject);
begin
  QuickRep1.Preview;
end;

procedure TForm1.ToolButton2Click(Sender: TObject);
begin
  QRPreview1.Zoom := SpinEdit1.Value;
end;

procedure TForm1.actPrevPageUpdate(Sender: TObject);
begin
  TAction(Sender).Enabled := Assigned(QuickRep1.QRPrinter) and
    (QRPreview1.PageNumber > 1);
end;

procedure TForm1.actPrevPageExecute(Sender: TObject);
begin
  QRPreview1.PageNumber := QRPreview1.PageNumber - 1;
end;

procedure TForm1.actNextPageUpdate(Sender: TObject);
begin
  TAction(Sender).Enabled := Assigned(QuickRep1.QRPrinter) and
    (QRPreview1.PageNumber < QuickRep1.QRPrinter.PageCount)
end;

procedure TForm1.actNextPageExecute(Sender: TObject);
begin
  QRPreview1.PageNumber := QRPreview1.PageNumber + 1;
end;

end.
And here's the form (change the database to the one you want):

object Form1: TForm1
  Left = 192
  Top = 106
  AutoScroll = False
  Caption = 'Form1'
  ClientHeight = 453
  ClientWidth = 688
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Scaled = False
  PixelsPerInch = 96
  TextHeight = 13
  object QuickRep1: TQuickRep
    Left = 8
    Top = 8
    Width = 794
    Height = 1123
    Frame.Color = clBlack
    Frame.DrawTop = False
    Frame.DrawBottom = False
    Frame.DrawLeft = False
    Frame.DrawRight = False
    DataSet = Table1
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'Arial'
    Font.Style = []
    Functions.Strings = (
      'PAGENUMBER'
      'COLUMNNUMBER'
      'REPORTTITLE')
    Functions.DATA = (
      '0'
      '0'
      #39#39)
    OnPreview = QuickRep1Preview
    Options = [FirstPageHeader, LastPageFooter]
    Page.Columns = 1
    Page.Orientation = poPortrait
    Page.PaperSize = A4
    Page.Values = (
      127
      2970
      127
      2100
      127
      127
      0)
    PrinterSettings.Copies = 1
    PrinterSettings.Duplex = False
    PrinterSettings.FirstPage = 0
    PrinterSettings.LastPage = 0
    PrinterSettings.OutputBin = Auto
    PrintIfEmpty = True
    SnapToGrid = True
    Units = Inches
    Zoom = 100
    object DetailBand1: TQRBand
      Left = 48
      Top = 48
      Width = 698
      Height = 40
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      AlignToBottom = False
      Color = clWhite
      ForceNewColumn = False
      ForceNewPage = False
      Size.Values = (
        105.833333333333
        1846.79166666667)
      BandType = rbDetail
      object QRDBText1: TQRDBText
        Left = 0
        Top = 8
        Width = 63
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          0
          21.1666666666667
          166.6875)
        Alignment = taLeftJustify
        AlignToBand = True
        AutoSize = True
        AutoStretch = False
        Color = clWhite
        DataSet = Table1
        DataField = 'Adr_Street'
        Transparent = False
        WordWrap = True
        FontSize = 10
      end
    end
  end
  object QRPreview1: TQRPreview
    Left = 0
    Top = 29
    Width = 688
    Height = 424
    HorzScrollBar.Tracking = True
    VertScrollBar.Tracking = True
    Align = alClient
    TabOrder = 1
    PageNumber = 1
    Zoom = 100
  end
  object ToolBar1: TToolBar
    Left = 0
    Top = 0
    Width = 688
    Height = 29
    ButtonHeight = 21
    ButtonWidth = 76
    Caption = 'ToolBar1'
    ShowCaptions = True
    TabOrder = 2
    object ToolButton1: TToolButton
      Left = 0
      Top = 2
      Caption = 'Preview'
      ImageIndex = 0
      OnClick = ToolButton1Click
    end
    object SpinEdit1: TSpinEdit
      Left = 76
      Top = 2
      Width = 59
      Height = 22
      MaxLength = 25
      MaxValue = 1000
      MinValue = 25
      TabOrder = 0
      Value = 100
    end
    object ToolButton2: TToolButton
      Left = 135
      Top = 2
      Caption = 'Zoom'
      ImageIndex = 1
      OnClick = ToolButton2Click
    end
    object ToolButton3: TToolButton
      Left = 211
      Top = 2
      Action = actPrevPage
    end
    object ToolButton4: TToolButton
      Left = 287
      Top = 2
      Action = actNextPage
    end
  end
  object Table1: TTable
    Active = True
    DatabaseName = 'Demo'
    TableName = 'Address'
    Left = 32
    Top = 320
  end
  object ActionList1: TActionList
    Left = 34
    Top = 63
    object actPrevPage: TAction
      Caption = 'Previous Page'
      OnExecute = actPrevPageExecute
      OnUpdate = actPrevPageUpdate
    end
    object actNextPage: TAction
      Caption = 'Next Page'
      OnExecute = actNextPageExecute
      OnUpdate = actNextPageUpdate
    end
  end
end











HTH
DragonSlayer
Avatar of penich
penich

Build your Qreport into a form and control the Qreport programmatically
it will help you in furute if you have any other requriments
Avatar of jlislo

ASKER

DragonSlayer,

I already have a prrview form designed for another project. What I want to know is any quick way to disable only the save/load function. Thanks.

JL
ASKER CERTIFIED SOLUTION
Avatar of jlislo
jlislo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jlislo:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.