home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
VWCIS
/
VWSAMPLE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-28
|
4KB
|
122 lines
{*******************************************************}
{ }
{ Vision Workshop for Turbo Vision }
{ Demo program }
{ }
{ o Shows how to use a menu bar stored in a }
{ resource file - see TVWSampleApp.InitMenuBar }
{ o Shows how to use a string table for the }
{ hints in the status line - see }
{ THintStatusLine.Hint }
{ o Shows how to use a standard dialog }
{ loaded from the resource file }
{ see TVWSampleApp.HandleEvent }
{ }
{ Copyright (c) 1992, 93 by FE }
{ }
{*******************************************************}
PROGRAM VWSample;
USES Objects, App, Drivers, Views, Menus, Dialogs;
VAR
RezFile: TResourceFile;
Strings: PStringList;
TYPE
TVWSampleApp = object(TApplication)
PROCEDURE HandleEvent(VAR Event: TEvent); VIRTUAL;
PROCEDURE InitMenuBar; VIRTUAL;
PROCEDURE InitStatusLine; VIRTUAL;
END;
PHintStatusLine = ^THintStatusLine;
THintStatusLine = OBJECT(TStatusLine)
FUNCTION Hint(AHelpCtx: Word): STRING; VIRTUAL;
END;
PROCEDURE TVWSampleApp.HandleEvent(VAR Event: TEvent);
VAR
R: TRect;
D: PDialog;
BEGIN
INHERITED HandleEvent(Event);
IF Event.What = evCommand THEN BEGIN
{ display dialog when user chooses "Open..." }
IF Event.Command = cmOpen THEN BEGIN
D := PDialog(RezFile.Get('Dialog'));
{ load dialog from resource file }
ExecuteDialog(D, NIL);
END;
END;
END;
PROCEDURE TVWSampleApp.InitMenuBar;
BEGIN
MenuBar := PMenuBar(RezFile.Get('MainMenu'));
{ load menu bar from resource file }
IF MenuBar = NIL THEN
Halt;
END;
PROCEDURE TVWSampleApp.InitStatusLine;
VAR
R: TRect;
BEGIN
GetExtent(R);
R.A.Y := R.B.Y - 1;
StatusLine := New(PHintStatusLine, Init(R,
NewStatusDef(hcDragging, hcDragging,
NewStatusKey('~F1~ Help', kbF1, cmHelp,
NewStatusKey('~'#24#25#26#27'~ Move', kbNoKey, 0,
NewStatusKey('~Shift-'#24#25#26#27'~ Resize', kbNoKey, 0,
NewStatusKey('~'#17#196#217'~ Done', kbNoKey, 0,
NewStatusKey('~Esc~ Cancel', kbNoKey, 0, NIL))))),
NewStatusDef(0, 999,
NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
NIL),
NIL))));
END;
{ Hint displays the strings stored in the string table retrieved
from the resource }
FUNCTION THintStatusLine.Hint(AHelpCtx: Word): STRING;
BEGIN
Hint := '';
IF Strings = NIL THEN
Exit;
Hint := Strings^.Get(AHelpCtx+10000);
{ we used an offset to make index unique }
END;
VAR
VWSampleApp: TVWSampleApp;
BEGIN
{ register all views needed by this application }
RegisterMenus;
RegisterDialogs;
RegisterViews;
RegisterObjects;
RegisterType(RStringList);
{ open the resource file appended to .EXE file - $40 in the open mode
is required when the resource has been appended to the .EXE file
in protected mode since RTM keeps the .EXE file open after loading }
{ RezFile.Init(New(PDosStream, Init(ParamStr(0), stOpenRead OR $40))); }
{ open the resource file stored in a separate file}
RezFile.Init(New(PDosStream, Init('VWSAMPLE.REZ', stOpenRead)));
{ load string table }
Strings := PStringList(RezFile.Get('Strings'));
VWSampleApp.Init;
VWSampleApp.Run;
VWSampleApp.Done;
IF Strings <> NIL THEN
Dispose(Strings, Done);
RezFile.Done;
END.