home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
developmen
/
ctrlhe
/
CTRLHELP.DOC
next >
Wrap
Text File
|
1992-07-07
|
3KB
|
69 lines
CTRLHELP.OPL and DOHELP.OPL
===========================
These programs show how you can handle the HELP key while in a dialog
or menu in an Opl program. The main program is of course deaf until
the menu or dialog terminates, and is not informed when HELP is
pressed, but you can arrange a background process to capture this
key and to present the Help information.
The tricky part is to make sure the subprocess only captures the HELP
key while the associated main program is in foreground. The
subprocess arranges that this is the case by repeatedly calling
wGetProcessList (CALL($d98d,...)) to see what the current foreground
application is.
The subprocess needs to know what the PID (process identifier) of the
main program is. One way to arrange this is for the main program to
inter-process copy its PID into the dataspace of the subprocess in
between creating the subprocess (CALL($0187)) and resuming it
(CALL($0688)). (All processes are created in an initially suspended
state.) I chose offset $28 in the dataspace as a safe "postbox". In
general, the seven words from $28 to $34 in the dataspace of an Opl
program are guaranteed never to be altered by any system code, and
are available for use as postboxes in this way.
Picking up the termination of the main program
----------------------------------------------
At the same time as the subprocess DoHelp checks to see what the
current foreground process is, it also checks whether the owning
process still exists. If not, the subprocess also terminates.
One way to check if a process with a given PID still exists is to
call wClientInfo (CALL($8c8d)), which will return a negative value if
the process no longer exists. (This only works for processes that
are clients of the Window Server.)
Checking for coming into foreground unexpectedly
------------------------------------------------
The subprocess ought only to come into foreground when it decides to
do so. Ie the user shouldn't be able to task it into foreground
"accidentally" (especially since it presents a worryingly blank
screen to the outside world).
Various approaches are possible here. First, if you give the
subprocess a name starting with SYS$, it will never be listed in the
top-level lists in the System Screen (but the user can still see it
by pressing TAB).
Second, the call wSystemModal can be used (in the routine LOCKBACK:)
to prevent the process being cycled into foreground, eg by
Shift+System or Shift+Control+Prog. Finally, the main loop checks to
see if the subprocess is unexpectedly in foreground, and if so, calls
LOCKBACK: again.
If you need more information
----------------------------
There are several aspects of CTRLHELP.OPL and DOHELP.OPL that are not
explained fully in this document. I have touched on similar points
in various comments here and there on CIX, but please feel free to
raise any questions you like about these more advanced uses of Opl,
eg in the main PSION SERIES3 conference. I won't mind repeating
myself (though I may take a few days or even weeks to get round to
answering your question), and it may be that I can give a clearer
answer the second time than the first time. As I said, even though
the information you need may already be available, it's not always
that accessible.
DavidW