home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / memsz200.zip / SUPPORT.CC < prev    next >
Text File  |  1993-06-05  |  33KB  |  895 lines

  1. /***************************************************************** SUPPORT.CC
  2.  *                                                                          *
  3.  *                Presentation Manager Support Functions                    *
  4.  *                                                                          *
  5.  ****************************************************************************/
  6.  
  7. #define INCL_BASE
  8. #define INCL_PM
  9. #include <os2.h>
  10.  
  11. #include <stdarg.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15.  
  16. #include "support.h"
  17. #include "debug.h"
  18.  
  19.  
  20. /****************************************************************************
  21.  *                                        *
  22.  *    Definitions & Declarations                        *
  23.  *                                        *
  24.  ****************************************************************************/
  25.  
  26.   // Local Function Prototypes
  27.  
  28. static USHORT BuildExtendedAttributeItem ( PFEA pFEA, PEADATA Item ) ;
  29.  
  30.  
  31. /****************************************************************************
  32.  *                                                                          *
  33.  *                        Message Dispatcher                                *
  34.  *                                                                          *
  35.  ****************************************************************************/
  36.  
  37. extern MRESULT DispatchMessage
  38. (
  39.   HWND    hwnd,
  40.   USHORT  msg,
  41.   MPARAM  mp1,
  42.   MPARAM  mp2,
  43.   PMETHOD MethodTable,
  44.   USHORT  MethodCount,
  45.   PFNWP   DefaultProcessor
  46. )
  47. {
  48.  /***************************************************************************
  49.   * Local Declarations                                                      *
  50.   ***************************************************************************/
  51.  
  52.   USHORT cNumberLeft ;
  53.   MRESULT mr ;
  54.   PMETHOD pMethod ;
  55.  
  56.  /***************************************************************************
  57.   * Process messages according to object's class method table.              *
  58.   ***************************************************************************/
  59.  
  60.   pMethod = MethodTable ;
  61.   cNumberLeft = MethodCount ;
  62.  
  63.   while ( ( cNumberLeft ) AND ( pMethod->Action != msg ) )
  64.   {
  65.     pMethod ++ ;
  66.     cNumberLeft -- ;
  67.   }
  68.  
  69.   if ( cNumberLeft )
  70.   {
  71.     mr = pMethod->pFunction ( hwnd, msg, mp1, mp2 ) ;
  72.   }
  73.   else
  74.   {
  75.     if ( DefaultProcessor )
  76.       mr = DefaultProcessor ( hwnd, msg, mp1, mp2 ) ;
  77.     else
  78.       mr = 0 ;
  79.   }
  80.  
  81.  /***************************************************************************
  82.   * Return result from message processor.                                   *
  83.   ***************************************************************************/
  84.  
  85.   return ( mr ) ;
  86. }
  87.  
  88. /****************************************************************************
  89.  *                                                                          *
  90.  *                         Add Item to System Menu                          *
  91.  *                                                                          *
  92.  ****************************************************************************/
  93.  
  94. extern VOID AddSysMenuItem ( HWND hwndFrame, MENUITEM *Item, PSZ Text )
  95. {
  96.  /***************************************************************************
  97.   * Local Declarations                                                      *
  98.   ***************************************************************************/
  99.  
  100.   HWND hwndSysMenu ;
  101.   HWND hwndSysSubMenu ;
  102.   USHORT idSysMenu ;
  103.   MENUITEM miSysMenu ;
  104.  
  105.  /***************************************************************************
  106.   * Obtain the system menu window handle.                                   *
  107.   ***************************************************************************/
  108.  
  109.   hwndSysMenu = WinWindowFromID ( hwndFrame, FID_SYSMENU ) ;
  110.  
  111.  /***************************************************************************
  112.   * Get the system menu's base item and its window handle.                  *
  113.   ***************************************************************************/
  114.  
  115.   idSysMenu = SHORT1FROMMR ( WinSendMsg ( hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL ) ) ;
  116.  
  117.   WinSendMsg ( hwndSysMenu, MM_QUERYITEM,
  118.     MPFROM2SHORT(idSysMenu,FALSE), MPFROMP(&miSysMenu) ) ;
  119.  
  120.   hwndSysSubMenu = miSysMenu.hwndSubMenu ;
  121.  
  122.  /***************************************************************************
  123.   * Add the new item to the system menu's submenu, which is what we see.    *
  124.   ***************************************************************************/
  125.  
  126.   WinSendMsg ( hwndSysSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  127. }
  128.  
  129. /****************************************************************************
  130.  *                                                                          *
  131.  *                   Add Item to Submenu on System Menu                     *
  132.  *                                                                          *
  133.  ****************************************************************************/
  134.  
  135. extern VOID AddSysSubMenuItem
  136. (
  137.   HWND hwndFrame,
  138.   USHORT SubMenuID,
  139.   MENUITEM *Item,
  140.   PSZ Text
  141. )
  142. {
  143.  /***************************************************************************
  144.   * Local Declarations                                                      *
  145.   ***************************************************************************/
  146.  
  147.   HWND hwndSubMenu ;
  148.   HWND hwndSysMenu ;
  149.   HWND hwndSysSubMenu ;
  150.   USHORT idSysMenu ;
  151.   MENUITEM MenuItem ;
  152.  
  153.  /***************************************************************************
  154.   * Obtain the system menu window handle.                                   *
  155.   ***************************************************************************/
  156.  
  157.   hwndSysMenu = WinWindowFromID ( hwndFrame, FID_SYSMENU ) ;
  158.  
  159.  /***************************************************************************
  160.   * Get the system menu's base item and its window handle.                  *
  161.   ***************************************************************************/
  162.  
  163.   idSysMenu = SHORT1FROMMR ( WinSendMsg ( hwndSysMenu, MM_ITEMIDFROMPOSITION, NULL, NULL ) ) ;
  164.  
  165.   WinSendMsg ( hwndSysMenu, MM_QUERYITEM,
  166.     MPFROM2SHORT(idSysMenu,FALSE), MPFROMP(&MenuItem) ) ;
  167.  
  168.   hwndSysSubMenu = MenuItem.hwndSubMenu ;
  169.  
  170.  /***************************************************************************
  171.   * Get the submenu's base item and its window handle.                      *
  172.   ***************************************************************************/
  173.  
  174.   WinSendMsg ( hwndSysSubMenu, MM_QUERYITEM,
  175.     MPFROM2SHORT ( SubMenuID, TRUE ),
  176.     (MPARAM) &MenuItem ) ;
  177.  
  178.   hwndSubMenu = MenuItem.hwndSubMenu ;
  179.  
  180.  /***************************************************************************
  181.   * Add the new item to the system menu's submenu, which is what we see.    *
  182.   ***************************************************************************/
  183.  
  184.   WinSendMsg ( hwndSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  185. }
  186.  
  187. /****************************************************************************
  188.  *                                                                          *
  189.  *                           Add Item to Menu                               *
  190.  *                                                                          *
  191.  ****************************************************************************/
  192.  
  193. extern VOID AddMenuItem
  194. (
  195.   HWND hwndFrame,
  196.   USHORT MenuID,
  197.   MENUITEM *Item,
  198.   PSZ Text
  199. )
  200. {
  201.  /***************************************************************************
  202.   * Local Declarations                                                      *
  203.   ***************************************************************************/
  204.  
  205.   HWND hwndMenu ;
  206.  
  207.  /***************************************************************************
  208.   * Obtain the menu window handle.                                          *
  209.   ***************************************************************************/
  210.  
  211.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  212.  
  213.  /***************************************************************************
  214.   * Add the new item to the menu.                                           *
  215.   ***************************************************************************/
  216.  
  217.   WinSendMsg ( hwndMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  218. }
  219.  
  220. /****************************************************************************
  221.  *                                                                          *
  222.  *                        Add Item to SubMenu                               *
  223.  *                                                                          *
  224.  ****************************************************************************/
  225.  
  226. extern VOID AddSubMenuItem
  227. (
  228.   HWND hwndFrame,
  229.   USHORT MenuID,
  230.   USHORT SubMenuID,
  231.   MENUITEM *Item,
  232.   PSZ Text
  233. )
  234. {
  235.  /***************************************************************************
  236.   * Local Declarations                                                      *
  237.   ***************************************************************************/
  238.  
  239.   HWND hwndMenu ;
  240.   HWND hwndSubMenu ;
  241.   MENUITEM MenuItem ;
  242.  
  243.  /***************************************************************************
  244.   * Obtain the menu window handle.                                          *
  245.   ***************************************************************************/
  246.  
  247.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  248.  
  249.  /***************************************************************************
  250.   * Obtain the submenu window handle.                                       *
  251.   ***************************************************************************/
  252.  
  253.   WinSendMsg ( hwndMenu, MM_QUERYITEM,
  254.     MPFROM2SHORT ( SubMenuID, TRUE ),
  255.     (MPARAM) &MenuItem ) ;
  256.  
  257.   hwndSubMenu = MenuItem.hwndSubMenu ;
  258.  
  259.  /***************************************************************************
  260.   * Add the new item to the menu.                                           *
  261.   ***************************************************************************/
  262.  
  263.   WinSendMsg ( hwndSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text) ) ;
  264. }
  265.  
  266. /****************************************************************************
  267.  *                                        *
  268.  *             Remove Item from SubMenu                *
  269.  *                                        *
  270.  ****************************************************************************/
  271.  
  272. extern VOID RemoveSubMenuItem
  273. (
  274.   HWND hwndFrame,
  275.   USHORT MenuID,
  276.   USHORT SubMenuID,
  277.   USHORT ItemID
  278. )
  279. {
  280.  /***************************************************************************
  281.   * Local Declarations                                *
  282.   ***************************************************************************/
  283.  
  284.   HWND hwndMenu ;
  285.   HWND hwndSubMenu ;
  286.   MENUITEM MenuItem ;
  287.  
  288.  /***************************************************************************
  289.   * Obtain the menu window handle.                        *
  290.   ***************************************************************************/
  291.  
  292.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  293.  
  294.  /***************************************************************************
  295.   * Obtain the submenu window handle.                        *
  296.   ***************************************************************************/
  297.  
  298.   WinSendMsg ( hwndMenu, MM_QUERYITEM,
  299.     MPFROM2SHORT ( SubMenuID, TRUE ),
  300.     (MPARAM) &MenuItem ) ;
  301.  
  302.   hwndSubMenu = MenuItem.hwndSubMenu ;
  303.  
  304.  /***************************************************************************
  305.   * Remove the item from the menu.                        *
  306.   ***************************************************************************/
  307.  
  308.   WinSendMsg ( hwndSubMenu, MM_REMOVEITEM, MPFROM2SHORT(ItemID,TRUE), 0 ) ;
  309. }
  310.  
  311. /****************************************************************************
  312.  *                                                                          *
  313.  *      Enable/Disable menu item.                                           *
  314.  *                                                                          *
  315.  ****************************************************************************/
  316.  
  317. extern VOID EnableMenuItem ( HWND hwndFrame, USHORT MenuID, USHORT ItemID, BOOL Enable )
  318. {
  319.  /***************************************************************************
  320.   * Local Declarations                                                      *
  321.   ***************************************************************************/
  322.  
  323.   HWND hwndMenu ;
  324.  
  325.  /***************************************************************************
  326.   * Get the menu's window handle.                                           *
  327.   ***************************************************************************/
  328.  
  329.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  330.  
  331.  /***************************************************************************
  332.   * Set the menu item's enable/disable status.                              *
  333.   ***************************************************************************/
  334.  
  335.   WinSendMsg ( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT ( ItemID, TRUE ),
  336.     MPFROM2SHORT ( MIA_DISABLED, Enable ? 0 : MIA_DISABLED ) ) ;
  337. }
  338.  
  339. /****************************************************************************
  340.  *                                                                          *
  341.  *      Check/Uncheck menu item.                                            *
  342.  *                                                                          *
  343.  ****************************************************************************/
  344.  
  345. extern VOID CheckMenuItem ( HWND hwndFrame, USHORT MenuID, USHORT ItemID, BOOL Enable )
  346. {
  347.  /***************************************************************************
  348.   * Local Declarations                                                      *
  349.   ***************************************************************************/
  350.  
  351.   HWND hwndMenu ;
  352.  
  353.  /***************************************************************************
  354.   * Get the menu's window handle.                                           *
  355.   ***************************************************************************/
  356.  
  357.   hwndMenu = WinWindowFromID ( hwndFrame, MenuID ) ;
  358.  
  359.  /***************************************************************************
  360.   * Set the menu item's enable/disable status.                              *
  361.   ***************************************************************************/
  362.  
  363.   WinSendMsg ( hwndMenu, MM_SETITEMATTR, MPFROM2SHORT ( ItemID, TRUE ),
  364.     MPFROM2SHORT ( MIA_CHECKED, Enable ? MIA_CHECKED : 0 ) ) ;
  365. }
  366.  
  367. /****************************************************************************
  368.  *                                                                          *
  369.  *                        Add Program to Task List                          *
  370.  *                                                                          *
  371.  ****************************************************************************/
  372.  
  373. extern VOID Add2TaskList ( HWND hwnd, PSZ Name )
  374. {
  375.  /***************************************************************************
  376.   * Local Declarations                                                      *
  377.   ***************************************************************************/
  378.  
  379.   PID pid ;
  380.   SWCNTRL swctl ;
  381.  
  382.  /***************************************************************************
  383.   * Get the window's process ID.                                            *
  384.   ***************************************************************************/
  385.  
  386.   WinQueryWindowProcess ( hwnd, &pid, NULL ) ;
  387.  
  388.  /***************************************************************************
  389.   * Add an entry to the system task list.                                   *
  390.   ***************************************************************************/
  391.  
  392.   swctl.hwnd = hwnd ;
  393.   swctl.hwndIcon = NULL ;
  394.   swctl.hprog = NULL ;
  395.   swctl.idProcess = pid ;
  396.   swctl.idSession = 0 ;
  397.   swctl.uchVisibility = SWL_VISIBLE ;
  398.   swctl.fbJump = SWL_JUMPABLE ;
  399.   strcpy ( swctl.szSwtitle, (PCHAR)Name ) ;
  400.  
  401.   WinAddSwitchEntry ( &swctl ) ;
  402. }
  403.  
  404. /****************************************************************************
  405.  *                                        *
  406.  *  Build Presentation Parameters                        *
  407.  *                                        *
  408.  ****************************************************************************/
  409.  
  410. extern PPRESPARAMS BuildPresParams
  411. (
  412.   USHORT ParmCount,
  413.   PULONG Ids,
  414.   PULONG ByteCounts,
  415.   PBYTE *Parms
  416. )
  417. {
  418.  /***************************************************************************
  419.   * Local Declarations                                *
  420.   ***************************************************************************/
  421.  
  422.   USHORT i ;
  423.   PPARAM Param ;
  424.   PPRESPARAMS PresParams ;
  425.   ULONG Size ;
  426.  
  427.  /***************************************************************************
  428.   * Determine final size of presentation parameter block.            *
  429.   ***************************************************************************/
  430.  
  431.   Size = sizeof(ULONG) ;
  432.  
  433.   for ( i=0; i<ParmCount; i++ )
  434.   {
  435.     Size += sizeof(ULONG) ;
  436.     Size += sizeof(ULONG) ;
  437.     Size += ByteCounts[i] ;
  438.   }
  439.  
  440.  /***************************************************************************
  441.   * Allocate memory for block.    Return if unable to do so.            *
  442.   ***************************************************************************/
  443.  
  444.   PresParams = (PPRESPARAMS) AllocateMemory ( (USHORT) Size ) ;
  445.  
  446.   if ( PresParams == NULL )
  447.     return ( NULL ) ;
  448.  
  449.  /***************************************************************************
  450.   * Initialize the block header.                        *
  451.   ***************************************************************************/
  452.  
  453.   PresParams->cb = Size - sizeof(PresParams->cb) ;
  454.  
  455.  /***************************************************************************
  456.   * Load the presentation parameters into the block.                *
  457.   ***************************************************************************/
  458.  
  459.   Param = PresParams->aparam ;
  460.  
  461.   for ( i=0; i<ParmCount; i++ )
  462.   {
  463.     Param->id = Ids[i] ;
  464.     Param->cb = ByteCounts[i] ;
  465.     memcpy ( Param->ab, Parms[i], (USHORT)ByteCounts[i] ) ;
  466.     ((PBYTE)Param) += sizeof(LONG) ;
  467.     ((PBYTE)Param) += sizeof(LONG) ;
  468.     ((PBYTE)Param) += ByteCounts[i] ;
  469.   }
  470.  
  471.  /***************************************************************************
  472.   * Return the pointer to the block.  It will need freeing by the caller.   *
  473.   ***************************************************************************/
  474.  
  475.   return ( PresParams ) ;
  476. }
  477.  
  478. /****************************************************************************
  479.  *                                        *
  480.  *    Build Extended Attributes                        *
  481.  *                                        *
  482.  ****************************************************************************/
  483.  
  484. extern PEAOP BuildExtendedAttributes ( USHORT Count, EADATA Table[] )
  485. {
  486.  /***************************************************************************
  487.   * Local Declarations                                *
  488.   ***************************************************************************/
  489.  
  490.   USHORT   cbEA ;
  491.   USHORT   i ;
  492.   PEAOP    pExtendedAttributes ;
  493.   PFEA       pFEA ;
  494.   PFEALIST pFEAList ;
  495.  
  496.  /***************************************************************************
  497.   * Find out how much memory will be needed for the block.            *
  498.   ***************************************************************************/
  499.  
  500.   cbEA = sizeof(FEALIST) - sizeof(FEA) ;
  501.  
  502.   for ( i=0; i<Count; i++ )
  503.   {
  504.     cbEA += BuildExtendedAttributeItem ( NULL, &Table[i] ) ;
  505.   }
  506.  
  507.  /***************************************************************************
  508.   * Allocate memory for the FEA list.                        *
  509.   ***************************************************************************/
  510.  
  511.   pFEAList = (PFEALIST) AllocateMemory ( cbEA ) ;
  512.  
  513.   if ( pFEAList == NULL )
  514.   {
  515.     return ( NULL ) ;
  516.   }
  517.  
  518.  /***************************************************************************
  519.   * Construct the extended attributes.                        *
  520.   ***************************************************************************/
  521.  
  522.   pFEA = pFEAList->list ;
  523.  
  524.   for ( i=0; i<Count; i++ )
  525.   {
  526.     (PBYTE) pFEA += BuildExtendedAttributeItem ( pFEA, &Table[i] ) ;
  527.   }
  528.  
  529.   pFEAList->cbList = (PBYTE) pFEA - (PBYTE) pFEAList ;
  530.  
  531.  /***************************************************************************
  532.   * Allocate memory for the EA header block.                    *
  533.   ***************************************************************************/
  534.  
  535.   pExtendedAttributes = (PEAOP) AllocateMemory ( sizeof(EAOP) ) ;
  536.  
  537.   if ( pExtendedAttributes == NULL )
  538.   {
  539.     FreeMemory ( pFEAList ) ;
  540.     return ( NULL ) ;
  541.   }
  542.  
  543.  /***************************************************************************
  544.   * Fill in the extended attribute header block and return its address.     *
  545.   ***************************************************************************/
  546.  
  547.   pExtendedAttributes->fpGEAList = NULL ;
  548.   pExtendedAttributes->fpFEAList = pFEAList ;
  549.   pExtendedAttributes->oError = 0 ;
  550.  
  551.   return ( pExtendedAttributes ) ;
  552. }
  553.  
  554. /****************************************************************************
  555.  *                                        *
  556.  *    Build Extended Attribute Item                        *
  557.  *                                        *
  558.  ****************************************************************************/
  559.  
  560. static USHORT BuildExtendedAttributeItem ( PFEA pFEA, PEADATA Item )
  561. {
  562.  /***************************************************************************
  563.   *                 Declarations                    *
  564.   ***************************************************************************/
  565.  
  566.   PBYTE p ;
  567.   PSHORT ps ;
  568.  
  569.  /***************************************************************************
  570.   * Store header.                                *
  571.   ***************************************************************************/
  572.  
  573.   p = (PBYTE) pFEA ;
  574.  
  575.   if ( pFEA )
  576.   {
  577.     pFEA->fEA = 0 ;
  578.     pFEA->cbName = (BYTE) strlen ( (PCHAR)Item->Name ) ;
  579.     pFEA->cbValue = Item->Length + 2 * sizeof(USHORT) ;
  580.   }
  581.  
  582.   p += sizeof(FEA) ;
  583.  
  584.  /***************************************************************************
  585.   * Store name.                                 *
  586.   ***************************************************************************/
  587.  
  588.   if ( pFEA )
  589.   {
  590.     strcpy ( (PCHAR)p, (PCHAR)Item->Name ) ;
  591.   }
  592.  
  593.   p += strlen ( (PCHAR)Item->Name ) + 1 ;
  594.  
  595.  /***************************************************************************
  596.   * Store value's type.                                                     *
  597.   ***************************************************************************/
  598.  
  599.   ps = (PSHORT) p ;
  600.  
  601.   if ( pFEA )
  602.   {
  603.     *ps = Item->Type ;
  604.   }
  605.  
  606.   ps ++ ;
  607.  
  608.  /***************************************************************************
  609.   * Store value's length.                                                   *
  610.   ***************************************************************************/
  611.  
  612.   if ( pFEA )
  613.   {
  614.     *ps = Item->Length ;
  615.   }
  616.  
  617.   ps ++ ;
  618.  
  619.  /***************************************************************************
  620.   * Store value.                                *
  621.   ***************************************************************************/
  622.  
  623.   p = (PBYTE) ps ;
  624.  
  625.   if ( pFEA )
  626.   {
  627.     memcpy ( p, Item->Value, Item->Length ) ;
  628.   }
  629.  
  630.   p += Item->Length ;
  631.  
  632.  /***************************************************************************
  633.   * Return count of bytes needed for item.                    *
  634.   ***************************************************************************/
  635.  
  636.   return ( p - (PBYTE)pFEA ) ;
  637. }
  638.  
  639. /****************************************************************************
  640.  *                                        *
  641.  *    Build Multi-Value Multi-Type EA Item's Value                        *
  642.  *                                        *
  643.  ****************************************************************************/
  644.  
  645. extern USHORT BuildMVMTValue ( PVOID Value, USHORT Count, MVMT_VALUE Table[] )
  646. {
  647.  /***************************************************************************
  648.   *                 Declarations                    *
  649.   ***************************************************************************/
  650.  
  651.   PBYTE p = (PBYTE) Value ;
  652.   USHORT i ;
  653.  
  654.  /***************************************************************************
  655.   * Store the number of values.                         *
  656.   ***************************************************************************/
  657.  
  658.   if ( Value )
  659.     *((PUSHORT)p) = Count ;
  660.   ((PUSHORT)p) ++ ;
  661.  
  662.  /***************************************************************************
  663.   * Store the multiple values.                            *
  664.   ***************************************************************************/
  665.  
  666.   for ( i=0; i<Count; i++ )
  667.   {
  668.     if ( Value )
  669.       *((PUSHORT)p) = Table[i].Type ;
  670.  
  671.     ((PUSHORT)p) ++ ;
  672.  
  673.     if ( Value )
  674.       *((PUSHORT)p) = Table[i].Length ;
  675.  
  676.     ((PUSHORT)p) ++ ;
  677.  
  678.     if ( Value )
  679.       memcpy ( p, Table[i].Value, Table[i].Length ) ;
  680.  
  681.     p += Table[i].Length ;
  682.   }
  683.  
  684.  /***************************************************************************
  685.   * Return the total byte count.                        *
  686.   ***************************************************************************/
  687.  
  688.   return ( p - (PBYTE)Value ) ;
  689. }
  690.  
  691. /****************************************************************************
  692.  *                                                                          *
  693.  *      Process Exit menu command.                                          *
  694.  *                                                                          *
  695.  ****************************************************************************/
  696.  
  697. extern MRESULT APIENTRY Exit
  698. (
  699.   HWND hwnd,
  700.   USHORT msg,
  701.   MPARAM mp1,
  702.   MPARAM mp2
  703. )
  704. {
  705.  /***************************************************************************
  706.   * Send a WM_CLOSE message to the window.                                  *
  707.   ***************************************************************************/
  708.  
  709.   WinSendMsg ( hwnd, WM_CLOSE, 0L, 0L ) ;
  710.  
  711.  /***************************************************************************
  712.   * Done.                                                                   *
  713.   ***************************************************************************/
  714.  
  715.   return ( MRFROMSHORT ( 0 ) ) ;
  716.  
  717.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  718. }
  719.  
  720. /****************************************************************************
  721.  *                                                                          *
  722.  *      Process Help For Help menu command.                                 *
  723.  *                                                                          *
  724.  ****************************************************************************/
  725.  
  726. extern MRESULT APIENTRY HelpForHelp
  727. (
  728.   HWND hwnd,
  729.   USHORT msg,
  730.   MPARAM mp1,
  731.   MPARAM mp2
  732. )
  733. {
  734.  /***************************************************************************
  735.   * Local Declarations                                                      *
  736.   ***************************************************************************/
  737.  
  738.   HWND hwndHelp ;
  739.  
  740.  /***************************************************************************
  741.   * Get the help instance window handle, if any.                            *
  742.   ***************************************************************************/
  743.  
  744.   hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  745.  
  746.  /***************************************************************************
  747.   * If help is available, pass the request on to the help window.           *
  748.   ***************************************************************************/
  749.  
  750.   if ( hwndHelp )
  751.   {
  752.     WinSendMsg ( hwndHelp, HM_DISPLAY_HELP, 0L, 0L ) ;
  753.   }
  754.  
  755.  /***************************************************************************
  756.   * Done.                                                                   *
  757.   ***************************************************************************/
  758.  
  759.   return ( MRFROMSHORT ( 0 ) ) ;
  760.  
  761.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  762. }
  763.  
  764. /****************************************************************************
  765.  *                                                                          *
  766.  *      Process Extended Help menu command.                                 *
  767.  *                                                                          *
  768.  ****************************************************************************/
  769.  
  770. extern MRESULT APIENTRY ExtendedHelp
  771. (
  772.   HWND hwnd,
  773.   USHORT msg,
  774.   MPARAM mp1,
  775.   MPARAM mp2
  776. )
  777. {
  778.  /***************************************************************************
  779.   * Local Declarations                                                      *
  780.   ***************************************************************************/
  781.  
  782.   HWND hwndHelp ;
  783.  
  784.  /***************************************************************************
  785.   * Get the help instance window handle, if any.                            *
  786.   ***************************************************************************/
  787.  
  788.   hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  789.  
  790.  /***************************************************************************
  791.   * If help is available, pass the request on to the help window.           *
  792.   ***************************************************************************/
  793.  
  794.   if ( hwndHelp )
  795.   {
  796.     WinSendMsg ( hwndHelp, HM_EXT_HELP, 0L, 0L ) ;
  797.   }
  798.  
  799.  /***************************************************************************
  800.   * Done.                                                                   *
  801.   ***************************************************************************/
  802.  
  803.   return ( MRFROMSHORT ( 0 ) ) ;
  804.  
  805.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  806. }
  807.  
  808. /****************************************************************************
  809.  *                                                                          *
  810.  *      Process Keys Help menu command.                                     *
  811.  *                                                                          *
  812.  ****************************************************************************/
  813.  
  814. extern MRESULT APIENTRY KeysHelp
  815. (
  816.   HWND hwnd,
  817.   USHORT msg,
  818.   MPARAM mp1,
  819.   MPARAM mp2
  820. )
  821. {
  822.  /***************************************************************************
  823.   * Local Declarations                                                      *
  824.   ***************************************************************************/
  825.  
  826.   HWND hwndHelp ;
  827.  
  828.  /***************************************************************************
  829.   * Get the help instance window handle, if any.                            *
  830.   ***************************************************************************/
  831.  
  832.   hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  833.  
  834.  /***************************************************************************
  835.   * If help is available, pass the request on to the help window.           *
  836.   ***************************************************************************/
  837.  
  838.   if ( hwndHelp )
  839.   {
  840.     WinSendMsg ( hwndHelp, HM_KEYS_HELP, 0L, 0L ) ;
  841.   }
  842.  
  843.  /***************************************************************************
  844.   * Done.                                                                   *
  845.   ***************************************************************************/
  846.  
  847.   return ( MRFROMSHORT ( 0 ) ) ;
  848.  
  849.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  850. }
  851.  
  852. /****************************************************************************
  853.  *                                                                          *
  854.  *      Process Help Index menu command.                                    *
  855.  *                                                                          *
  856.  ****************************************************************************/
  857.  
  858. extern MRESULT APIENTRY HelpIndex
  859. (
  860.   HWND hwnd,
  861.   USHORT msg,
  862.   MPARAM mp1,
  863.   MPARAM mp2
  864. )
  865. {
  866.  /***************************************************************************
  867.   * Local Declarations                                                      *
  868.   ***************************************************************************/
  869.  
  870.   HWND hwndHelp ;
  871.  
  872.  /***************************************************************************
  873.   * Get the help instance window handle, if any.                            *
  874.   ***************************************************************************/
  875.  
  876.   hwndHelp = WinQueryHelpInstance ( hwnd ) ;
  877.  
  878.  /***************************************************************************
  879.   * If help is available, pass the request on to the help window.           *
  880.   ***************************************************************************/
  881.  
  882.   if ( hwndHelp )
  883.   {
  884.     WinSendMsg ( hwndHelp, HM_HELP_INDEX, 0L, 0L ) ;
  885.   }
  886.  
  887.  /***************************************************************************
  888.   * Done.                                                                   *
  889.   ***************************************************************************/
  890.  
  891.   return ( MRFROMSHORT ( 0 ) ) ;
  892.  
  893.   hwnd = hwnd ;  msg = msg ;  mp1 = mp1 ;  mp2 = mp2 ;
  894. }
  895.