home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
LPEX.ZIP
/
LPEXPROG.INF
(
.txt
)
< prev
next >
Wrap
OS/2 Help File
|
1991-12-16
|
44KB
|
126 lines
ΓòÉΓòÉΓòÉ 1. About this Book ΓòÉΓòÉΓòÉ
The author is Steve Hall.
This book describes programming enhancements to LPEX developed by the author.
ΓòÉΓòÉΓòÉ 2. Presentation Manager Messages ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ 2.1. LP_COMMAND ΓòÉΓòÉΓòÉ
LP_COMMAND executes a command string.
The message can be issued from the same process (for example, from within an
LPEX command or parser), or from a different process. It is necessary to
distinguish between these two cases because interprocess addressability to the
command string is more complex than intraprocess addressability.
The message can be directed to either the message window, or to any document or
view window. In the case of a document or view window, it is possible indicate
that the command be executed for the document or view in the window, as opposed
to the current document and view, which may be different.
In the former case, the target window is activated for the duration of the
command execution, and the originally current document and view is reinstated
afterwards, if that is still possible. Note that this will nullify the effect
of commands such as GODOC, which are best directed to the message window.
If the message is directed to the message window, then the command is always
executed for the current document and view (if any) and any indication to the
contrary is ignored.
Example: Interprocess Command Execution to the Message Window
char * pszCommand = "GODOC DOCNUM 1" ; // Command to be executed.
HWND hwndLpex ; // Handle of the LPEX message window.
SEL selExport ; // The selector as seen by this process.
short sObjectSize ; // Size of the shared segment.
// Get givable segment of suitable size for the command string.
// The segment will be shared between this process and the LPEX process.
// Note that each process has a different selector for it.
sObjectSize = strlen( pszCommand ) + 1 ; // Allow for trailing null.
if ( DosAllocSeg( sObjectSize, & selExport,
SEG_GIVEABLE | SEG_GETTABLE ) ) {
// Error creating shared segment for command string.
} else {
char * pszBuffer ;
PID pidLpex ; // LPEX process id.
SEL selImport ; // The selector as the LPEX process will see it.
TID tidLpex ; // LPEX thread id.
// Fill the shared segment with the command string.
pszBuffer = (char *)MAKEP( selExport, 0 ); // Address givable segment.
strcpy( pszBuffer, pszCommand ); // Copy the command to the shared segment.
// Determine the LPEX process id (the thread is of no interest).
WinQueryWindowProcess( hwndLpex, & pidLpex, & tidLpex );
// Give the shared segment to LPEX.
if ( DosGiveSeg( selExport, pidLpex, & selImport ) ) {
// Error giving shared segment containing command string.
} else {
// Give the command message to LPEX for asynchronous execution.
WinPostMsg( hwndLpex, LP_COMMAND,
MPFROMSHORT( selImport ),
MPFROM2SHORT( LP_COMMAND_EXTERNAL, LP_COMMAND_CURRENT ) );
// Discard the shared segment. Now only LPEX has addressability,
// and LPEX will discard the shared segment also
// (asynchronously) when it has finished with it.
if ( DosFreeSeg( selExport ) ) {
// Error freeing shared segment containing command string.
}
}
}
Note that in the above example, the LP_COMMAND_CURRENT option is in fact
enforced because the message is directed to the message window.
Example: Intraprocess Command Execution to a Document Window
char * pszCommand = "SET VIEWHELP TEST" ; // Command to be executed.
HWND hwndLpex ; // Handle of an LPEX document or view window.
// Give the command message to LPEX for execution now.
WinSendMsg( hwndLpex, LP_COMMAND,
(MPARAM)pszCommand,
MPFROM2SHORT( LP_COMMAND_INTERNAL, LP_COMMAND_WINDOWED ) );
Note that in the above example, the LP_COMMAND_WINDOWED option will temporarily
activate the target window to ensure that the command is executed against that
window.
Use the LP_COMMAND_CURRENT option for best performance, but take care that the
current document and view are the correct targets. Target the message window
for best performance.
Note When using WinPostMsg and LP_COMMAND_INTERNAL be aware that the command
string addressed by mp1 must be valid at the time the command is eventually
executed.
ΓòÉΓòÉΓòÉ 3. Help ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ 3.1. Help for Custom Dialogs ΓòÉΓòÉΓòÉ
Help can be provided for custom dialogs by using a range of reserved dialog
ids. The range of reserved ids is 9900 through 9931. Help can only be provided
in the form of extended help for the entire dialog.
o The resource (res=) value in the help library should correspond to the
dialog id. The help library should be added to appropriate document views
using the SET VIEWHELP command.
o The dialog window should be owned by the appropriate document view window,
and should be a child of the desk-top.