home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kompon / d23456 / CAJSCRTP.ZIP / demo_kylix / FormTest.ifs < prev    next >
Text File  |  2001-05-14  |  2KB  |  106 lines

  1. Program IFSTest;
  2. var
  3.   F, Form: TForm;
  4.   Label: TLabel;
  5.   Button: TButton;
  6.   Edit: TEdit;
  7.   Stop: Boolean;
  8. procedure MyOnCloseQuery(Sender: TObject; var CanClose: Boolean);
  9. begin
  10.   CanClose := Stop;
  11. end;
  12. procedure c2(sender: TObject);
  13. begin
  14.   f.Close;
  15. end;
  16.  
  17. procedure buttonclick(sender: TObject);
  18. begin
  19.   if Length(Edit.Text) < 5 then 
  20.   begin
  21.      f := TForm.Create;
  22.      with f do
  23.      begin
  24.        Width := 100;
  25.        Height := 100;
  26.        BorderStyle := bsDialog;
  27.        BorderIcons := 0;
  28.        Caption := 'Error';
  29.        Center;
  30.  
  31.       with TLabel.Create(F) do
  32.       begin
  33.          Left := 10;
  34.          Top := 10;
  35.          Width := 100;
  36.          Height := 50;
  37.          Caption := 'Invalid name';
  38.       end;
  39.       With TButton.Create(F) do
  40.       begin
  41.           Left:=10;
  42.           Top := 40;
  43.           Caption := 'OK';
  44.           Default := True;
  45.           Cancel := True;
  46.           OnClick := @C2;
  47.       end;
  48.        Visible := True;
  49.        form.Visible := False;
  50.        while f.Visible do
  51.        begin
  52.          ProcessMessages;
  53.        end;
  54.         Form.Visible := True;
  55.      end;
  56.   end else begin
  57.     writeln('debug:'+Edit.Text);
  58.     Stop := True;
  59.     Form.Close;
  60.   end;
  61. end;
  62. Begin
  63.   Form := TForm.Create;
  64.   Form.Width := 400;
  65.   Form.Height := 300;
  66.   Form.BorderStyle := bsDialog;
  67.   Form.BorderIcons := 0;
  68.   Form.OnCloseQuery := @MyOnCloseQuery;
  69.   Form.Caption := 'Name';
  70.   Form.Center;
  71.   Label := TLabel.Create(Form);
  72.   Label.Top := 120;
  73.   Label.Left := 160;
  74.   Label.Caption := 'Please type in your name:';
  75.   Edit := TEdit.Create(Form);
  76.   Edit.FontName := 'Tahoma';
  77.   Edit.SetBounds(160,160,80,24);
  78.   Button := TButton.Create(Form);
  79.   Button.Left := 160;
  80.   Button.Top := 200;
  81.   Button.Width := 80;
  82.   Button.Height := 24;
  83.   Button.Caption := '&OK';
  84.   Button.OnClick := @buttonclick ;
  85.   Button.Default := True;
  86.   with TMemo.Create(Form) do
  87.   begin
  88.     Left := 10;
  89.     Width := 380; 
  90.     Top := 10;
  91.     Height := 100;
  92.     Text := 'Welcome to Form Test.'#13#10#13#10'Type here your name (min 5 letters).  You can''t exit this demo without it.';
  93.     Color := 0;
  94.     FontColor := $FFFFFF;
  95.     Readonly := True;
  96.   end;
  97.   Form.Visible := true;
  98.   stop := false;
  99.   while Form.Visible  do
  100.   begin
  101.     ProcessMessages;
  102.   end;
  103.   Button.Free;
  104.   Form.Free;
  105. End.
  106.