| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 
 |  
program InputBox_01;
 
uses
  Objects, Drivers, Views, Menus, Dialogs, App, MsgBox;
 
var
  s_entree: string;
 
type
  tA = object(tApplication)
         constructor Init;
         procedure NewDialog;
       end;
 
  pD = ^tD;
  tD = object(tDialog)
         procedure HandleEvent(var e: tEvent); virtual;
       end;
 
procedure Traitement;
begin
  MessageBox(#3 + 'Vous vous appelez ' + s_entree + '.',
             nil,
             mfInformation or mfOKButton);
end;
 
constructor tA.Init;
begin
  TApplication.Init;
  s_entree := '';
  NewDialog;
end;
 
procedure tA.NewDialog;
var
  v: pView;
  d: pD;
  r: tRect;
begin
  r.Assign(1, 1, 30, 8);
  d := New(pD, Init(r, 'Votre nom ?'));
  with d^ do
  begin
    r.Assign(03, 02, 26, 03);
    v := New(pInputLine, Init(r, 10));
    Insert(v);
    r.Assign(03, 04, 14, 06);
    Insert(New(pButton, Init(r, 'Ok', cmOk, bfNormal)));
    r.Assign(16, 04, 27, 06);
    Insert(New(pButton, Init(r, 'Cancel', cmCancel, bfNormal)));
  end;
  d^.SetData(s_entree);
  DeskTop^.Insert(d);
end;
 
procedure tD.HandleEvent(var e: tEvent);
begin
  tDialog.HandleEvent(e);
  if e.What = EvCommand then
    case e.Command of
      cmOK: begin
              GetData(s_entree);
              tDialog.Done;
              Traitement;
            end;
      cmCancel: tDialog.done;
    end
  else
    Exit;
  ClearEvent(e);
end;
 
var
  a: tA;
 
begin
  a.Init;
  a.Run;
  a.Done;
end. | 
Partager