home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kompon / d3456 / POWERPDF.ZIP / PowerPdf / Example / OpenActionExample / Unit1.pas < prev   
Pascal/Delphi Source File  |  2001-09-15  |  4KB  |  154 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls, PReport, PdfDoc, ComCtrls, ShellAPI;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     RadioGroup1: TRadioGroup;
  13.     PRPage1: TPRPage;
  14.     PReport1: TPReport;
  15.     PRLayoutPanel1: TPRLayoutPanel;
  16.     PRLabel1: TPRLabel;
  17.     PRLabel2: TPRLabel;
  18.     PRLabel3: TPRLabel;
  19.     PRLabel4: TPRLabel;
  20.     PRLabel5: TPRLabel;
  21.     PRLabel6: TPRLabel;
  22.     PRLabel7: TPRLabel;
  23.     PRLabel8: TPRLabel;
  24.     PRLabel9: TPRLabel;
  25.     PRLabel10: TPRLabel;
  26.     PRLabel11: TPRLabel;
  27.     PRLabel12: TPRLabel;
  28.     Label1: TLabel;
  29.     Label2: TLabel;
  30.     Label3: TLabel;
  31.     Label4: TLabel;
  32.     Label5: TLabel;
  33.     EdtLeft: TEdit;
  34.     UpDown1: TUpDown;
  35.     EdtTop: TEdit;
  36.     UpDown2: TUpDown;
  37.     EdtRight: TEdit;
  38.     UpDown3: TUpDown;
  39.     EdtBottom: TEdit;
  40.     UpDown4: TUpDown;
  41.     EdtZoom: TEdit;
  42.     UpDown5: TUpDown;
  43.     PRLabel13: TPRLabel;
  44.     PRLabel14: TPRLabel;
  45.     PRLabel15: TPRLabel;
  46.     PRLabel16: TPRLabel;
  47.     PRLabel17: TPRLabel;
  48.     PRLabel18: TPRLabel;
  49.     PRLabel19: TPRLabel;
  50.     PRLabel20: TPRLabel;
  51.     PRLabel21: TPRLabel;
  52.     PRLabel22: TPRLabel;
  53.     PRLabel23: TPRLabel;
  54.     PRLabel24: TPRLabel;
  55.     PRLabel25: TPRLabel;
  56.     PRLabel26: TPRLabel;
  57.     PRLabel27: TPRLabel;
  58.     procedure Button1Click(Sender: TObject);
  59.     procedure PRPage1PrintPage(Sender: TObject; ACanvas: TPRCanvas);
  60.     procedure RadioGroup1Click(Sender: TObject);
  61.   private
  62.     { Private ÉΘî╛ }
  63.   public
  64.     { Public ÉΘî╛ }
  65.   end;
  66.  
  67. var
  68.   Form1: TForm1;
  69.  
  70. implementation
  71.  
  72. {$R *.DFM}
  73.  
  74. procedure TForm1.Button1Click(Sender: TObject);
  75. begin
  76.   with PReport1 do
  77.   begin
  78.     BeginDoc;
  79.     Print(PRPage1);
  80.     EndDoc;
  81.   end;
  82.   ShellExecute(Self.Handle, 'Open', 'default.pdf', '', '', SW_SHOW);
  83. end;
  84.  
  85. procedure TForm1.PRPage1PrintPage(Sender: TObject; ACanvas: TPRCanvas);
  86. var
  87.   Dest: TPRDestination;
  88. begin
  89.   // create a new destination for the current page.
  90.   Dest := PReport1.CreateDestination;
  91.  
  92.   // setting the properties for the destination object.
  93.   with Dest do
  94.   begin
  95.     DestinationType := TPRDestinationType(RadioGroup1.ItemIndex);
  96.     Left := StrToInt(EdtLeft.Text);
  97.     Top := StrToInt(EdtTop.Text);
  98.     Right := StrToInt(EdtRight.Text);
  99.     Bottom := StrToInt(EdtBottom.Text);
  100.     Zoom := StrToInt(EdtZoom.Text) / 100;
  101.   end;
  102.  
  103.   // set the destination object as the open-action.
  104.   PReport1.OpenAction := Dest;
  105. end;
  106.  
  107. procedure TForm1.RadioGroup1Click(Sender: TObject);
  108. begin
  109.   case RadioGroup1.ItemIndex of
  110.     0: begin
  111.          EdtTop.Enabled := true;
  112.          EdtLeft.Enabled := true;
  113.          EdtZoom.Enabled := true;
  114.          EdtRight.Enabled := false;
  115.          EdtBottom.Enabled := false;
  116.        end;
  117.     1, 5:
  118.        begin
  119.          EdtTop.Enabled := false;
  120.          EdtLeft.Enabled := false;
  121.          EdtZoom.Enabled := false;
  122.          EdtRight.Enabled := false;
  123.          EdtBottom.Enabled := false;
  124.        end;
  125.     2, 6:
  126.        begin
  127.          EdtTop.Enabled := true;
  128.          EdtLeft.Enabled := false;
  129.          EdtZoom.Enabled := false;
  130.          EdtRight.Enabled := false;
  131.          EdtBottom.Enabled := false;
  132.        end;
  133.     3, 7:
  134.        begin
  135.          EdtTop.Enabled := false;
  136.          EdtLeft.Enabled := true;
  137.          EdtZoom.Enabled := false;
  138.          EdtRight.Enabled := false;
  139.          EdtBottom.Enabled := false;
  140.        end;
  141.     4:
  142.        begin
  143.          EdtTop.Enabled := true;
  144.          EdtLeft.Enabled := true;
  145.          EdtZoom.Enabled := false;
  146.          EdtRight.Enabled := true;
  147.          EdtBottom.Enabled := true;
  148.        end;
  149.   end;
  150.  
  151. end;
  152.  
  153. end.
  154.