home *** CD-ROM | disk | FTP | other *** search
- {************************************************}
- { }
- { Turbo Pascal 6.0 }
- { Demo program from the Turbo Vision Guide }
- { }
- { Copyright (c) 1990 by Borland International }
- { }
- {************************************************}
-
- program Hello;
-
- uses Objects, Drivers, Views, Menus, Dialogs, App,
- {***} Dos, Help_Cmd, Screen;
-
- const
- GreetThemCmd = 100;
-
- type
- PHelloApp = ^THelloApp;
- THelloApp = object(TApplication)
-
- {***} Toggles : PToggleKeysView;
- {***} constructor Init;
- {***} procedure Idle; virtual;
-
- procedure GreetingBox;
- procedure HandleEvent(var Event: TEvent); virtual;
- procedure InitMenuBar; virtual;
- procedure InitStatusLine; virtual;
- end;
-
- { THelloApp }
- {***} constructor THelloApp.Init;
- {***}
- {***} var
- {***} R: TRect;
- {***}
- {***} begin
- {***} TApplication.Init;
- {***} GetExtent(R);
- {***} Dec(R.B.X);
- {***} R.A.X := R.B.X - 16;
- {***} R.A.Y := R.B.Y - 1;
- {***} Toggles := New(PToggleKeysView, Init(R) );
- {***} insert( Toggles );
- {***} end;
- {***}
- {***} procedure THelloApp.Idle;
- {***}
- {***} begin
- {***} TApplication.Idle;
- {***} Toggles^.UpDate;
- {***} CheckIfKeyPressed( THelloApp.GetHelpCtx );
- {***} end;
-
-
- procedure THelloApp.GreetingBox;
- var
- R: TRect;
- D: PDialog;
- C: Word;
- begin
- { Create a dialog }
- R.Assign(25, 5, 55, 16);
- D := New(PDialog, Init(R, 'Hello, World!'));
-
- { Create and insert controls into the dialog}
- R.Assign(3, 5, 15, 6);
- D^.Insert(New(PStaticText, Init(R, 'How are you?')));
-
- R.Assign(16, 2, 28, 4);
- D^.Insert(New(PButton, Init(R, 'Terrific', cmCancel, bfNormal)));
-
- R.Assign(16, 4, 28, 6);
- D^.Insert(New(PButton, Init(R, 'Ok', cmCancel, bfNormal)));
-
- R.Assign(16, 6, 28, 8);
- D^.Insert(New(PButton, Init(R, 'Lousy', cmCancel, bfNormal)));
-
- R.Assign(16, 8, 28, 10);
- D^.Insert( New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
-
- { Execute the modal dialog }
- C := DeskTop^.ExecView(D);
- end;
-
- procedure THelloApp.HandleEvent(var Event: TEvent);
- begin
- TApplication.HandleEvent(Event);
- if Event.What = evCommand then
- begin
- case Event.Command of
- GreetThemCmd: GreetingBox;
- else
- Exit;
- end;
- ClearEvent(Event);
- end;
- end;
-
- procedure THelloApp.InitMenuBar;
- var
- R: TRect;
- begin
- GetExtent(R);
- R.B.Y := R.A.Y + 1;
- MenuBar := New(PMenuBar, Init(R, NewMenu(
- NewSubMenu('~H~ello', hcNoContext, NewMenu(
- NewItem('~G~reeting...','', 0, GreetThemCmd, hcNoContext,
- NewLine(
- NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext,
- nil)))),
- nil))));
- end;
-
- procedure THelloApp.InitStatusLine;
- var
- R: TRect;
- begin
- GetExtent(R);
- R.A.Y := R.B.Y-1;
- StatusLine := New(PStatusLine, Init(R,
- {***
- Note the change in help context range, from $FFFF to 0.
- This would normaly be the last 'normal' help context.
- At the bottom of the help context list would be Shift, Ctrl and Alt.
- ***}
- NewStatusDef(0, 0,
- NewStatusKey('', kbF10, cmMenu,
- NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
- nil)),
- {***} NewStatusDef(hcShiftKeys, hcShiftkeys,
- {***} NewStatusKey('Shift: ~F6~-Previous', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~Del~-Cut', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~Ins~-Paste', kbNoKey, cmNoCommand,
- {***} nil))),
- {***} NewStatusDef(hcCtrlKeys, hcCtrlKeys,
- {***} NewStatusKey('Ctrl: ~Ins~-Copy',kbNoKey, cmNoCommand,
- {***} NewStatusKey('~Del~-Clear', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~F5~-Size/Move', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~QF~-Find', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~QA~-Replace', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~L~-Search Again', kbNoKey, cmNoCommand,
- {***} nil)))))),
- {***} NewStatusDef(hcAltKeys, hcAltKeys,
- {***} NewStatusKey('Alt: ~X~-Exit', kbAltX, cmQuit,
- {***} NewStatusKey('~F3~-Close', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~F5~-DOS Screen', kbNoKey, cmNoCommand,
- {***} NewStatusKey('~F9~-Compile', kbNoKey, cmNoCommand,
- {***} nil)))),
- nil))))));
- end;
-
- var
- HelloWorld: THelloApp;
-
- begin
- HelloWorld.Init;
- HelloWorld.Run;
- HelloWorld.Done;
- end.