home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / delite / hello / hello.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-04-01  |  2.1 KB  |  79 lines

  1. PROGRAM hello;
  2.  
  3. USES  Kernel, API, Dialogs;
  4.  
  5. CONST ProjektName  = 'hello';               { so heissen alle Dateien  }
  6.  
  7. VAR   LaunchResult      : integer;
  8.       MyEvent           : EventTyp;         { eine Botschaft        }
  9.       StillRunning      : boolean;
  10.  
  11. procedure SayHello;                         { Die "Greeting Box" }
  12. var MyDialog: Dialog;
  13.     MyButton: PButton;
  14.     MyLabel : PLabelFrame;
  15. begin
  16.   MyDialog.Init(330,120, MF_CAPTION, DefEventProc);
  17.   MyDialog.SetCaption('Greeting Window');
  18.   MyDialog.SetTopic('Hi there!');
  19.  
  20.   new(MyLabel, Init(20,15,290,95,  99, 'How are you?'));
  21.   MyDialog.AddItem(MyLabel);
  22.  
  23.   new(MyButton, Init(30, 30, 120, 30,  1, 'Terrific'));
  24.   MyDialog.AddItem(MyButton);
  25.   MyButton^.MakeDefaultItem;
  26.  
  27.   new(MyButton, Init(30, 70,120, 30,  2, 'OK'));
  28.   MyDialog.AddItem(MyButton);
  29.   MyButton^.MakeDefaultItem;
  30.  
  31.   new(MyButton, Init(180, 30,120, 30,  3, 'Lousy'));
  32.   MyDialog.AddItem(MyButton);
  33.   MyButton^.MakeDefaultItem;
  34.  
  35.   new(MyButton, Init(180, 70, 120, 30,  4, 'Cancel'));
  36.   MyDialog.AddItem(MyButton);
  37.   MyButton^.MakeCancelItem;
  38.  
  39.   MyDialog.Show;
  40.   MyDialog.DoDialog;
  41.   MyDialog.Done;
  42. end;
  43.  
  44.  
  45. Procedure HandleMsg(MyMessage: EventTyp); far;
  46. { Hier werden die Botschaften behandelt. }
  47. Begin
  48.   With MyMessage Do
  49.     Case Class Of
  50.       Menu    : begin
  51.                   Case MenuItemID of
  52.                      0       : StillRunning := false;  { Ende }
  53.                      101     : SayHello;               { Begrüßung }
  54.                   end;
  55.                 end;
  56.     end; { Case Class }
  57. End;
  58.  
  59.  
  60. Begin
  61.   StillRunning := true;
  62.   LaunchResult := OpenMainApplication(HandleMsg,
  63.                                           APP_NOFONT,
  64.                                           ProjektName);
  65.  
  66.   If LaunchResult = 0 then                { erfolgreich gestartet }
  67.   begin
  68.     while StillRunning Do
  69.        begin
  70.         GetEvent(MyEvent);
  71.         DispatchMessage(MyEvent);
  72.       end;
  73.     CloseMainApplication;
  74.   end
  75.   Else
  76.     Writeln('Programm kann nicht gestartet werden. Fehler: ',LaunchResult);
  77. End.
  78.  
  79.