unit UDemoADOApp;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, MRViewer, Db, DBTables, ExtCtrls, ComCtrls, AdoIntmr;

type
  TForm1 = class(TForm)
    MRViewer: TMRViewer;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Bevel1: TBevel;
    ProgressBar: TProgressBar;
    Button2: TButton;
    Panel1: TPanel;
    Label6: TLabel;
    Label7: TLabel;
    RGType: TRadioGroup;
    RGReport: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure MRViewerProgress(Position: Integer);
    procedure MRViewerActivateConnection(var Connection: _Connection;
      var Accept: Boolean);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    AppConnection: _Connection;
    ConnCreated: Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
begin
    if ConnCreated then
        try
            if RGType.ItemIndex = 0 then
            begin
               case RGReport.ItemIndex of
                 0: MRViewer.LoadReport('..\..\Reports\DemoGraph1.mrp');
                 1: MRViewer.LoadReport('..\..\Reports\DemoGraph2.mrp');
                 2: MRViewer.LoadReport('..\..\Reports\DemoGraph3.mrp');
               end;
            end
            else
            begin
               case RGReport.ItemIndex of
                 0: MRViewer.LoadReport('..\..\Reports\Demo1.mrp');
                 1: MRViewer.LoadReport('..\..\Reports\Demo2.mrp');
                 2: MRViewer.LoadReport('..\..\Reports\Demo3.mrp');
               end;
            end;
            MRViewer.Preview;
        finally
            MRViewer.UnLoadReport;
        end
    else
       ShowMessage('You must create ADO connection at first.');
end;

procedure TForm1.MRViewerProgress(Position: Integer);
begin
    ProgressBar.Position := Position;
end;

procedure TForm1.MRViewerActivateConnection(var Connection: _Connection;
  var Accept: Boolean);
begin
    Connection := AppConnection;
    Accept := True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
     AppConnection := CoConnection.Create;
     AppConnection.Open('DSN=MarshalDemo', '', '', 0);
     ConnCreated := True;
     ShowMessage('ADO connection was created.');
end;

end.
