home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / Duck Report / _SETUP.1 / PrintFo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-11-25  |  2.1 KB  |  96 lines

  1. unit PrintFo;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Spin, ExtCtrls;
  8.  
  9. type
  10.   TFormPrint = class(TForm)
  11.     Label1: TLabel;
  12.     Label2: TLabel;
  13.     Label3: TLabel;
  14.     Label4: TLabel;
  15.     BOK: TButton;
  16.     BCancel: TButton;
  17.     Label5: TLabel;
  18.     Label6: TLabel;
  19.     ELeft: TEdit;
  20.     ETop: TEdit;
  21.     EWidth: TEdit;
  22.     Bevel1: TBevel;
  23.     procedure BOKClick(Sender: TObject);
  24.     procedure BCancelClick(Sender: TObject);
  25.     procedure FormShow(Sender: TObject);
  26.     procedure FormCreate(Sender: TObject);
  27.   private
  28.         Function    GetReal (StText: String; Var rValue: Real): Boolean;
  29.   public
  30.         rLeft, rTop, rBarWidth:    Real;
  31.   end;
  32.  
  33. var
  34.   FormPrint: TFormPrint;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39. Procedure TFormPrint.FormCreate(Sender: TObject);
  40. Begin
  41.     rLeft            := 50;
  42.   rTop            := 10;
  43.   rBarWidth    := 0.20;
  44. End;
  45. Procedure TFormPrint.FormShow(Sender: TObject);
  46. Begin
  47.   ELeft.Text    := FormatFloat ('0.00', rLeft);
  48.   ETop.Text    := FormatFloat ('0.00', rTop);
  49.     EWidth.Text    := FormatFloat ('0.00', rBarWidth);
  50. End;
  51. Function TFormPrint.GetReal (StText: String; Var rValue: Real): Boolean;
  52. Var
  53.     i:            Integer;
  54.   iLength:    Integer;
  55. Begin
  56.     Result    := FALSE;
  57.   iLength    := Length (StText);
  58.   For i := 1 To iLength Do
  59.   Begin
  60.       if not (StText[i] in [DecimalSeparator,'0'..'9']) Then
  61.          Exit;
  62.   End;
  63.   rValue    := StrToFloat (StText);
  64.   Result    := TRUE;
  65. End;
  66. Procedure TFormPrint.BOKClick(Sender: TObject);
  67. Begin
  68.     if not GetReal (ELeft.Text, rLeft) Then
  69.   Begin
  70.       MessageDlg ('Left Error', mtError, [mbOK], 0);
  71.      ELeft.SetFocus;
  72.      Exit;
  73.   End;
  74.   if not GetReal (ETop.Text, rTop) Then
  75.   Begin
  76.       MessageDlg ('Top Error', mtError, [mbOK], 0);
  77.      ETop.SetFocus;
  78.      Exit;
  79.   End;
  80.   if not GetReal (EWidth.Text, rBarWidth) Then
  81.   Begin
  82.       MessageDlg ('Bar Width Error', mtError, [mbOK], 0);
  83.      EWidth.SetFocus;
  84.      Exit;
  85.   End;
  86.     Close;
  87.   ModalResult    := mrOK;
  88. End;
  89. Procedure TFormPrint.BCancelClick(Sender: TObject);
  90. Begin
  91.     Close;
  92.   ModalResult    := mrCancel;
  93. End;
  94.  
  95. End.
  96.