home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
VWCIS
/
VWPOPUP.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-28
|
3KB
|
110 lines
{*******************************************************}
{ }
{ Vision Workshop for Turbo Vision }
{ Demo program }
{ }
{ o Shows how to use a popup menu stored in a }
{ resource file - see }
{ TPopupEditWindow.HandleEvent }
{ o Shows how to use a menu bar stored in a }
{ resource file - see TVWPopupApp.InitMenuBar }
{ }
{ Copyright (c) 1992, 93 by FE }
{ }
{*******************************************************}
PROGRAM VWPopup;
USES Objects, App, Memory, Drivers, Views, Menus, Dialogs, Editors;
CONST
cmOpenEditor = 100;
VAR
RezFile: TResourceFile;
TYPE
TVWPopupApp = object(TApplication)
CONSTRUCTOR Init;
PROCEDURE HandleEvent(VAR Event: TEvent); VIRTUAL;
PROCEDURE InitMenuBar; VIRTUAL;
END;
PPopupEditWindow = ^TPopupEditWindow;
TPopupEditWindow = OBJECT(TEditWindow)
PROCEDURE HandleEvent(VAR Event: TEvent); VIRTUAL;
END;
{ Open a local popup menu at the mouse position when the right mouse button
has been pressed }
PROCEDURE TPopupEditWindow.HandleEvent(VAR Event: TEvent);
VAR
Popup: PMenuPopup;
BEGIN
IF (Event.What = evMouseDown) AND (Event.Buttons = mbRightButton) THEN BEGIN
{ load popup menu from resource }
Popup := PMenuPopup(RezFile.Get('Popup'));
{ adjust popup menu }
Popup^.MoveTo(Event.Where.X, Event.Where.Y);
{ insert local menu }
DeskTop^.Insert(Popup);
{ activate it }
Message(Popup, evCommand, cmMenu, NIL);
Dispose(Popup, Done);
ClearEvent(Event);
END;
INHERITED HandleEvent(Event);
END;
CONSTRUCTOR TVWPopupApp.Init;
BEGIN
MaxHeapSize := 8192;
EditorDialog := StdEditorDialog;
INHERITED Init;
END;
PROCEDURE TVWPopupApp.HandleEvent(VAR Event: TEvent);
VAR
R: TRect;
D: PDialog;
BEGIN
INHERITED HandleEvent(Event);
IF (Event.What = evCommand) AND (Event.Command = cmOpenEditor) THEN BEGIN
DeskTop^.GetExtent(R);
Application^.InsertWindow(New(PPopupEditWindow,
Init(R, '', wnNoNumber)));
END;
END;
PROCEDURE TVWPopupApp.InitMenuBar;
BEGIN
MenuBar := PMenuBar(RezFile.Get('MainMenu'));
{ load menu bar from resource file }
IF MenuBar = NIL THEN
Halt;
END;
VAR
VWPopupApp: TVWPopupApp;
BEGIN
{ register all views needed by this application }
RegisterMenus;
RegisterViews;
RegisterObjects;
{ 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('VWPOPUP.REZ', stOpenRead)));
VWPopupApp.Init;
VWPopupApp.Run;
VWPopupApp.Done;
RezFile.Done;
END.