Category : Pascal Source Code
Archive   : PASS_ALL.ZIP
Filename : TI668.ASC

 
Output of file : TI668.ASC contained in archive : PASS_ALL.ZIP








PRODUCT : Turbo Pascal NUMBER : 668
VERSION : 6.0
OS : MS/PC DOS
DATE : February 28, 1992 PAGE : 1/4

TITLE : Dual Input Lines in Turbo Vision




{

This program will create a record structure of two strings
and initialize them with data then read them into a
TInputLine. The program will use the SetData and GetData
methods to load and store data from the TInputLine Object.

}
{$X+}
program DualInputExample;

uses Objects, Drivers, Views, Menus, Dialogs, App;

const
cmNewDialog = 100;
hcMyDialog = 300;

type
MyData = record
Mystr1:String[10]; { Create a Record Structure }
MyStr2:String[10]; { for Input Lines in Dialog }
end;

var
RMyData: MyData; { Declare the Structure }

type
TMyApp = object(TApplication)
constructor Init;
procedure HandleEvent(var Event: TEvent); virtual;
procedure InitMenuBar; virtual;
procedure NewDialog;
end;

PDemoDialog = ^TDemoDialog;
TDemoDialog = object(TDialog)
Procedure HandleEvent(var Event:TEvent);virtual;
end;

constructor TMyApp.Init;
var
R : TRect;
begin













PRODUCT : Turbo Pascal NUMBER : 668
VERSION : 6.0
OS : MS/PC DOS
DATE : February 28, 1992 PAGE : 2/4

TITLE : Dual Input Lines in Turbo Vision




TApplication.Init; { Initialize data }
RMydata.MYstr1:='What';
RMydata.MYstr2:='Cheese';
GetExtent(R);
Dec(R.B.X);
R.A.X := R.B.X - 9; R.A.Y := R.B.Y - 1;
end;
{ TMyApp }

Procedure TDemoDialog.HandleEvent(var Event:TEvent);
begin
TDialog.HandleEvent(Event);
if Event.What = EvCommand then
begin
if event.what = EvCommand then
case Event.Command of
cmOK:begin
GetData(RMyData); { This will retrieve the }
{ information corresponding to }
{ a previous SetData and load }
{ the changed values in the }
{ record structure }
TDialog.Done;
end;
cmCancel:TDialog.Done;
end
else
Exit;
end;
clearEvent(Event);
end;

procedure TMyApp.HandleEvent(var Event: TEvent);
begin
TApplication.HandleEvent(Event);
if Event.What = evCommand then
begin
case Event.Command of
cmNewDialog: NewDialog;
else
Exit;
end;
ClearEvent(Event);













PRODUCT : Turbo Pascal NUMBER : 668
VERSION : 6.0
OS : MS/PC DOS
DATE : February 28, 1992 PAGE : 3/4

TITLE : Dual Input Lines in Turbo Vision




end;
end;

procedure TMyApp.InitMenuBar;
var
R: TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar := New(PMenuBar, Init(R, NewMenu(
NewSubMenu('~F~ile', hcNoContext, NewMenu(
NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext,
nil)),
NewSubMenu('~W~indow', hcNoContext, NewMenu(
NewItem('~D~ialog','F2', kbF2, cmNewDialog, hcmyDialog,
nil)),
nil))
)));
end;

procedure TMyApp.NewDialog;
var
Borland: PView;
Dialog: PDemoDialog;
R: TRect;
C: Word;
begin
R.Assign(20, 6, 60, 19);
Dialog := New(PDemoDialog, Init(R, 'Demo Dialog'));
with Dialog^ do
begin
R.Assign(3, 3, 18, 4);
Borland := New(PInputLine, Init(R,10));
Insert(Borland); { The order of insertion is directly }
{ related to the order of data items in }
{ the data structure }
R.Assign(3, 4, 18, 5);
Borland := New(PInputLine, Init(R,10));
Insert(Borland);
R.Assign(2, 2, 10, 3);
Insert(New(PLabel, Init(R, 'Cheeses', Borland)));
R.Assign(22, 3, 34, 5);
Borland := New(PRadioButtons, Init(R,













PRODUCT : Turbo Pascal NUMBER : 668
VERSION : 6.0
OS : MS/PC DOS
DATE : February 28, 1992 PAGE : 4/4

TITLE : Dual Input Lines in Turbo Vision




NewSItem('~R~unny',
NewSItem('~M~elted',
nil)))
);
Insert(Borland);
R.Assign(21, 2, 33, 3);
Insert(New(PLabel, Init(R, 'Consistency', Borland)));
R.Assign(15, 8, 25, 10);
Insert(New(PButton, Init(R, '~O~k', cmOk, bfDefault)));
R.Assign(28, 8, 38, 10);
Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
end;
Dialog^.SetData(RMyData); { Associate data to dialog }
{ input lines }
DeskTop^.Insert(Dialog);
end;
var
MyApp: TMyApp;

begin

MyApp.Init;
MyApp.Run;
MyApp.Done;
end.