home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / delphi / cbsuite.lzh / SU1SRC.ZIP / REPMAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1996-12-09  |  5KB  |  174 lines

  1. unit Repmain;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  6.   StdCtrls, ExtCtrls, Dialogs, PrnFile, CB_Types, RepDem01,
  7.   RepDem02, RepDem03, RepDem04, RepDem05, RepDem06, RepDem07, RepDem08,
  8.   CB_MFunc;
  9.  
  10. type
  11.   TMainReport = class(TForm)
  12.     Label1: TLabel;
  13.     Panel1: TPanel;
  14.     Bevel1: TBevel;
  15.     ListBox1: TListBox;
  16.     View: TButton;
  17.     Exit: TButton;
  18.     Printer: TButton;
  19.     PrinterSetupDialog1: TPrinterSetupDialog;
  20.     Printit: TLabel;
  21.     Label2: TLabel;
  22.     Label3: TLabel;
  23.     OpenDialog1: TOpenDialog;
  24.     PrintFile1: TPrintFile;
  25.     procedure ExitClick(Sender: TObject);
  26.     procedure ViewClick(Sender: TObject);
  27.     procedure PrinterClick(Sender: TObject);
  28.     procedure ListBox1DblClick(Sender: TObject);
  29.   private
  30.     { Private declarations }
  31.   public
  32.     { Public declarations }
  33.   end;
  34.  
  35. var
  36.   MainReport: TMainReport;
  37.  
  38. implementation
  39.  
  40. {$R *.DFM}
  41.  
  42. procedure TMainReport.ExitClick(Sender: TObject);
  43. begin
  44.     Close;
  45. end;
  46.  
  47. procedure TMainReport.ViewClick(Sender: TObject);
  48. var
  49.     OpenDialog1: TOpenDialog;
  50.  
  51. begin
  52.     if ListBox1.ItemIndex < 0 then
  53.     MessageDlg('Please select an option from the List Box', mtInformation,
  54.       [mbOk], 0);
  55.  
  56.     if (ListBox1.ItemIndex >= 0) then begin
  57.        case ListBox1.ItemIndex of
  58.        0: begin
  59.            dem01form := Tdem01form.Create (Application);
  60.           dem01form.ShowModal;
  61.           dem01form.Free;
  62.           end;
  63.        1: begin
  64.            dem02form := Tdem02form.Create (Application);
  65.           dem02form.ShowModal;
  66.           dem02form.Free;
  67.           end;
  68.        2: begin
  69.            dem03form := Tdem03form.Create (Application);
  70.           dem03form.ShowModal;
  71.           dem03form.Free;
  72.           end;
  73.        3: begin
  74.            dem04form := Tdem04form.Create (Application);
  75.           dem04form.ShowModal;
  76.           dem04form.Free;
  77.          end;
  78.        4: begin
  79.            dem05form := Tdem05form.Create (Application);
  80.           dem05form.ShowModal;
  81.           dem05form.Free;
  82.           end;
  83.        5: begin
  84.            dem08form := Tdem08form.Create (Application);
  85.           dem08form.ShowModal;
  86.           dem08form.Free;
  87.          end;
  88.        6: begin
  89.            dem06form := Tdem06form.Create (Application);
  90.           dem06form.ShowModal;
  91.           dem06form.Free;
  92.           end;
  93.        7: begin
  94.            dem07form := Tdem07form.Create (Application);
  95.           dem07form.ShowModal;
  96.           dem07form.Free;
  97.           end;
  98.           
  99.  
  100.        8: begin
  101.                 OpenDialog1 := TOpenDialog.Create(Application);
  102.                 OpenDialog1.Filter := 'Text files (*.TXT)|*.TXT|Pascal files (*.PAS)' +
  103.                     '|*.PAS|Quattro Pro files (*.WB1)|*.WB1|All Files (*.*)|*.*';
  104.  
  105.                 OpenDialog1.FileName := '';
  106.                 if OpenDialog1.Execute then begin
  107.                     PrintFile1.Filename := OpenDialog1.FileName;
  108.                     PrintFile1.PageLayout := pl_1x2;
  109.                     PrintFile1.HeaderStringCenter := OpenDialog1.FileName;
  110.                     PrintFile1.Execute;
  111.                 end;
  112.                 OpenDialog1.Free;
  113.           end;
  114.        9: begin
  115.                  OpenDialog1 := TOpenDialog.Create(Application);
  116.                  OpenDialog1.Filter := 'Text files (*.TXT)|*.TXT|Pascal files (*.PAS)' +
  117.                     '|*.PAS|Quattro Pro files (*.WB1)|*.WB1|All Files (*.*)|*.*';
  118.  
  119.                  OpenDialog1.FileName := '';
  120.                  if OpenDialog1.Execute then begin
  121.                      PrintFile1.Filename := OpenDialog1.FileName;
  122.                     PrintFile1.PageLayout := pl_1x3;
  123.                   PrintFile1.HeaderStringCenter := OpenDialog1.FileName;
  124.                     PrintFile1.Execute;
  125.                  end;
  126.                  OpenDialog1.Free;
  127.           end;
  128.       10: begin
  129.                 PrintFile1.Input := frHTML;
  130.                 OpenDialog1 := TOpenDialog.Create(Application);
  131.                 OpenDialog1.Filter := 'HTML files (*.HTM)|*.HTM';
  132.  
  133.                 OpenDialog1.FileName := '';
  134.                 if OpenDialog1.Execute then begin
  135.                     PrintFile1.Filename := OpenDialog1.FileName;
  136.                     PrintFile1.PageLayout := pl_1x2;
  137.                     PrintFile1.HeaderStringCenter := OpenDialog1.FileName;
  138.                     PrintFile1.Execute;
  139.                 end;
  140.                 OpenDialog1.Free;
  141.                 PrintFile1.Input := frFile;
  142.           end;
  143.        11: begin
  144.               PrintFile1.Input := frHTML;
  145.                 OpenDialog1 := TOpenDialog.Create(Application);
  146.                 OpenDialog1.Filter := 'HTML files (*.HTM)|*.HTM';
  147.  
  148.                 OpenDialog1.FileName := '';
  149.                 if OpenDialog1.Execute then begin
  150.                     PrintFile1.Filename := OpenDialog1.FileName;
  151.                     PrintFile1.PageLayout := pl_1x3;
  152.                     PrintFile1.HeaderStringCenter := OpenDialog1.FileName;
  153.                     PrintFile1.Execute;
  154.                 end;
  155.               PrintFile1.Input := frFile;
  156.                 OpenDialog1.Free;
  157.           end;
  158.  
  159.        end;
  160.    end;
  161. end;
  162.  
  163. procedure TMainReport.PrinterClick(Sender: TObject);
  164. begin
  165.     PrinterSetupDialog1.Execute;
  166. end;
  167.  
  168. procedure TMainReport.ListBox1DblClick(Sender: TObject);
  169. begin
  170.     ViewClick(Sender);
  171. end;
  172.  
  173. end.
  174.