home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / LPEX.ZIP / LPEXPROG.INF (.txt) < prev    next >
OS/2 Help File  |  1991-12-16  |  44KB  |  126 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. About this Book ΓòÉΓòÉΓòÉ
  3.  
  4. The author is Steve Hall. 
  5. This book describes programming enhancements to LPEX developed by the author. 
  6.  
  7.  
  8. ΓòÉΓòÉΓòÉ 2. Presentation Manager Messages ΓòÉΓòÉΓòÉ
  9.  
  10.  
  11. ΓòÉΓòÉΓòÉ 2.1. LP_COMMAND ΓòÉΓòÉΓòÉ
  12.  
  13. LP_COMMAND executes a command string. 
  14.  
  15. The message can be issued from the same process (for example, from within an 
  16. LPEX command or parser), or from a different process. It is necessary to 
  17. distinguish between these two cases because interprocess addressability to the 
  18. command string is more complex than intraprocess addressability. 
  19.  
  20. The message can be directed to either the message window, or to any document or 
  21. view window. In the case of a document or view window, it is possible indicate 
  22. that the command be executed for the document or view in the window, as opposed 
  23. to the current document and view, which may be different. 
  24.  
  25. In the former case, the target window is activated for the duration of the 
  26. command execution, and the originally current document and view is reinstated 
  27. afterwards, if that is still possible. Note that this will nullify the effect 
  28. of commands such as GODOC, which are best directed to the message window. 
  29.  
  30. If the message is directed to the message window, then the command is always 
  31. executed for the current document and view (if any) and any indication to the 
  32. contrary is ignored. 
  33.  
  34. Example: Interprocess Command Execution to the Message Window 
  35.  
  36. char * pszCommand = "GODOC DOCNUM 1" ; // Command to be executed.
  37. HWND hwndLpex ;     // Handle of the LPEX message window.
  38. SEL selExport ;     // The selector as seen by this process.
  39. short sObjectSize ; // Size of the shared segment.
  40.  
  41. // Get givable segment of suitable size for the command string.
  42. // The segment will be shared between this process and the LPEX process.
  43. // Note that each process has a different selector for it.
  44. sObjectSize = strlen( pszCommand ) + 1 ; // Allow for trailing null.
  45. if ( DosAllocSeg( sObjectSize, & selExport,
  46.                   SEG_GIVEABLE | SEG_GETTABLE ) ) {
  47.  
  48.   // Error creating shared segment for command string.
  49.  
  50. } else {
  51.   char * pszBuffer ;
  52.   PID pidLpex ;   // LPEX process id.
  53.   SEL selImport ; // The selector as the LPEX process will see it.
  54.   TID tidLpex ;   // LPEX thread id.
  55.  
  56.   // Fill the shared segment with the command string.
  57.   pszBuffer = (char *)MAKEP( selExport, 0 ); // Address givable segment.
  58.   strcpy( pszBuffer, pszCommand ); // Copy the command to the shared segment.
  59.  
  60.   // Determine the LPEX process id (the thread is of no interest).
  61.   WinQueryWindowProcess( hwndLpex, & pidLpex, & tidLpex );
  62.  
  63.   // Give the shared segment to LPEX.
  64.   if ( DosGiveSeg( selExport, pidLpex, & selImport ) ) {
  65.  
  66.     // Error giving shared segment containing command string.
  67.  
  68.   } else {
  69.     // Give the command message to LPEX for asynchronous execution.
  70.     WinPostMsg( hwndLpex, LP_COMMAND,
  71.                 MPFROMSHORT( selImport ),
  72.                 MPFROM2SHORT( LP_COMMAND_EXTERNAL, LP_COMMAND_CURRENT ) );
  73.  
  74.     // Discard the shared segment. Now only LPEX has addressability,
  75.     // and LPEX will discard the shared segment also
  76.     // (asynchronously) when it has finished with it.
  77.     if ( DosFreeSeg( selExport ) ) {
  78.  
  79.       // Error freeing shared segment containing command string.
  80.  
  81.     }
  82.   }
  83. }
  84.  
  85. Note that in the above example, the LP_COMMAND_CURRENT option is in fact 
  86. enforced because the message is directed to the message window. 
  87.  
  88. Example: Intraprocess Command Execution to a Document Window 
  89.  
  90. char * pszCommand = "SET VIEWHELP TEST" ; // Command to be executed.
  91. HWND hwndLpex ;     // Handle of an LPEX document or view window.
  92.  
  93. // Give the command message to LPEX for execution now.
  94. WinSendMsg( hwndLpex, LP_COMMAND,
  95.             (MPARAM)pszCommand,
  96.             MPFROM2SHORT( LP_COMMAND_INTERNAL, LP_COMMAND_WINDOWED ) );
  97.  
  98. Note that in the above example, the LP_COMMAND_WINDOWED option will temporarily 
  99. activate the target window to ensure that the command is executed against that 
  100. window. 
  101.  
  102. Use the LP_COMMAND_CURRENT option for best performance, but take care that the 
  103. current document and view are the correct targets. Target the message window 
  104. for best performance. 
  105.  
  106. Note When using WinPostMsg and LP_COMMAND_INTERNAL be aware that the command 
  107. string addressed by mp1 must be valid at the time the command is eventually 
  108. executed. 
  109.  
  110.  
  111. ΓòÉΓòÉΓòÉ 3. Help ΓòÉΓòÉΓòÉ
  112.  
  113.  
  114. ΓòÉΓòÉΓòÉ 3.1. Help for Custom Dialogs ΓòÉΓòÉΓòÉ
  115.  
  116. Help can be provided for custom dialogs by using a range of reserved dialog 
  117. ids. The range of reserved ids is 9900 through 9931. Help can only be provided 
  118. in the form of extended help for the entire dialog. 
  119.  
  120.  o The resource (res=) value in the help library should correspond to the 
  121.    dialog id. The help library should be added to appropriate document views 
  122.    using the SET VIEWHELP command. 
  123.  
  124.  o The dialog window should be owned by the appropriate document view window, 
  125.    and should be a child of the desk-top. 
  126.