home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / SAMPLES / BIDI / HEBREW / STYLE / STY_HELP.C < prev    next >
C/C++ Source or Header  |  1995-08-24  |  11KB  |  372 lines

  1. /*************************************************************************
  2. *
  3. *  File Name   : STY_HELP.C
  4. *
  5. *  Description : This module contains all the routines for
  6. *         interfacing with the IPF help manager.
  7. *
  8. *  Concepts    : Help initialization and termination, handling of
  9. *         help menu items.
  10. *
  11. *  API's       : WinCreateHelpInstance
  12. *         WinAssociateHelpInstance
  13. *         WinLoadString
  14. *         WinSendMsg
  15. *         WinDlgBox
  16. *         WinDestroyHelpInstance
  17. *
  18. *  Copyright (C) 1992 IBM Corporation
  19. *
  20. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  21. *      sample code created by IBM Corporation. This sample code is not
  22. *      part of any standard or IBM product and is provided to you solely
  23. *      for  the purpose of assisting you in the development of your
  24. *      applications.  The code is provided "AS IS", without
  25. *      warranty of any kind.  IBM shall not be liable for any damages
  26. *      arising out of your use of the sample code, even if they have been
  27. *      advised of the possibility of such damages.                              *
  28. *
  29. ************************************************************************/
  30.  
  31. /*  Include files, macros, defined constants, and externs    */
  32.  
  33. #define  INCL_WINHELP
  34. #define  INCL_DOSFILEMGR
  35. #define  INCL_DOSMISC
  36.  
  37. #include <os2.h>
  38. #include <string.h>
  39. #include "sty_main.h"
  40. #include "sty_xtrn.h"
  41. #include "sty_dlg.h"
  42. #include "sty_help.h"
  43.  
  44. #define HELPLIBRARYNAMELEN  20
  45.  
  46. /*  Global variables                        */
  47. static HWND hwndHelpInstance;
  48. static CHAR szLibName[HELPLIBRARYNAMELEN];
  49. static CHAR szWindowTitle[HELPLIBRARYNAMELEN];
  50.  
  51.  
  52. /*  Entry point declarations                    */
  53. MRESULT EXPENTRY ProdInfoDlgProc(HWND hwnd, USHORT msg,
  54.                  MPARAM mp1, MPARAM mp2);
  55.  
  56. /***************************************************************
  57.  *  Name: InitHelp
  58.  *
  59.  *  Description : Initializes the IPF help facility
  60.  *
  61.  *  Concepts : Initializes the HELPINIT structure and creates the
  62.  *           help instance.  If successful, the help instance
  63.  *           is associated with the main window
  64.  *
  65.  *  API's : WinCreateHelpInstance
  66.  *        WinAssociateHelpInstance
  67.  *        WinLoadString
  68.  *
  69.  *  Parameters : None
  70.  *
  71.  *  Returns:  None
  72.  *
  73.  ****************************************************************/
  74. VOID InitHelp(VOID)
  75. {
  76.   HELPINIT helpInit;
  77.  
  78.   /* if we return because of an error, Help will be disabled            */
  79.   fHelpEnabled = FALSE;
  80.  
  81.   /* inititalize help init structure                        */
  82.   helpInit.cb = sizeof(HELPINIT);
  83.   helpInit.ulReturnCode = 0L;
  84.  
  85.   helpInit.pszTutorialName = (PSZ)NULL;   /* if tutorial added,         */
  86.                       /* add name here            */
  87.   helpInit.phtHelpTable = (PHELPTABLE)MAKELONG(STYLE_HELP_TABLE,
  88.                0xFFFF);
  89.   helpInit.hmodHelpTableModule = (HMODULE)0;
  90.   helpInit.hmodAccelActionBarModule = (HMODULE)0;
  91.   helpInit.idAccelTable = 0;
  92.   helpInit.idActionBar = 0;
  93.  
  94.   if (!WinLoadString(hab, (HMODULE)0, IDS_HELPWINDOWTITLE,
  95.             HELPLIBRARYNAMELEN, (PSZ)szWindowTitle))
  96.   {
  97.      MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
  98.      return;
  99.   }
  100.   helpInit.pszHelpWindowTitle = (PSZ)szWindowTitle;
  101.   helpInit.fShowPanelId = CMIC_HIDE_PANEL_ID;
  102.  
  103.   if (!WinLoadString(hab, (HMODULE)0, IDS_HELPLIBRARYNAME,
  104.        HELPLIBRARYNAMELEN, (PSZ)szLibName))
  105.   {
  106.      MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
  107.      return;
  108.   }
  109.  
  110.   helpInit.pszHelpLibraryName = (PSZ)szLibName;
  111.  
  112.   /* creating help instance                            */
  113.   hwndHelpInstance = WinCreateHelpInstance(hab, &helpInit);
  114.  
  115.   if (!hwndHelpInstance || helpInit.ulReturnCode)
  116.   {
  117.      MessageBox(hwndMainFrame, IDMSG_HELPLOADERROR, MB_OK | MB_ERROR, TRUE);
  118.      return;
  119.   }
  120.  
  121.   /* associate help instance with main frame                    */
  122.   if (!WinAssociateHelpInstance(hwndHelpInstance, hwndMainFrame))
  123.   {
  124.      MessageBox(hwndMainFrame, IDMSG_HELPLOADERROR, MB_OK | MB_ERROR, TRUE);
  125.      return;
  126.   }
  127.  
  128.   /* help manager is successfully initialized so set flag to TRUE        */
  129.   fHelpEnabled = TRUE;
  130.  
  131. }   /*                        End of InitHelp()        */
  132.  
  133. /*********************************************************************
  134.  *  Name: HelpUsingHelp
  135.  *
  136.  *  Description : Processes the WM_COMMAND message posted
  137.  *          by the Using Help item of the Help menu
  138.  *
  139.  *  Concepts : Called from MainCommand when the Using Help menu item
  140.  *           is selected.  Sends an HM_DISPLAY_HELP message to the
  141.  *           help instance so that the default Using Help is
  142.  *           displayed.
  143.  *
  144.  *  API's : WinSendMsg
  145.  *
  146.  *  Parameters :  mp2 - Message parameter 2
  147.  *
  148.  *  Returns: None
  149.  *
  150.  ****************************************************************/
  151. VOID  HelpUsingHelp(MPARAM mp2)
  152. {
  153. /*    this just displays the system help for help panel               */
  154.   if (fHelpEnabled)
  155.   {
  156.     if ((BOOL)WinSendMsg(hwndHelpInstance, HM_DISPLAY_HELP, NULL, NULL))
  157.     {
  158.        MessageBox(hwndMain, IDMSG_HELPDISPLAYERROR, MB_OK | MB_ERROR, FALSE);
  159.     }
  160.   }
  161.  /*
  162.   * This routine currently doesn't use the mp2 parameter but
  163.   * it is referenced here to prevent an 'Unreferenced Parameter'
  164.   * warning at compile time.
  165.   */
  166.   mp2;
  167. }   /* End of HelpUsingHelp()                             */
  168.  
  169. /*********************************************************************
  170.  
  171.  *  Name: HelpUsingHelp
  172.  *
  173.  *  Description : Processes the WM_COMMAND message posted
  174.  *          by the General Help item of the Help menu
  175.  *
  176.  *  Concepts : Called from MainCommand when the General Help menu item
  177.  *           is selected.  Sends an HM_EXT_HELP message to the
  178.  *           help instance so that the default Extended Help is
  179.  *           displayed.
  180.  *
  181.  *  API's : WinSendMsg
  182.  *
  183.  *  Parameters :  mp2 - Message parameter 2
  184.  *
  185.  
  186.  *  Returns: None
  187.  *
  188.  ****************************************************************/
  189. VOID  HelpGeneral(MPARAM mp2)
  190. {
  191. /*   this just displays the system General help panel                */
  192.    if (fHelpEnabled)
  193.    {
  194.      if ((BOOL)WinSendMsg(hwndHelpInstance, HM_EXT_HELP, NULL, NULL))
  195.      {
  196.     MessageBox(hwndMain, IDMSG_HELPDISPLAYERROR, MB_OK | MB_ERROR, FALSE);
  197.      }
  198.    }
  199.    /*
  200.     * This routine currently doesn't use the mp2 parameter but
  201.     * it is referenced here to prevent an 'Unreferenced Parameter'
  202.     * warning at compile time.
  203.     */
  204.     mp2;
  205.  
  206. }    /* End of HelpGeneral()                      */
  207.  
  208. /*********************************************************************
  209.  *  Name: HelpKeys
  210.  *
  211.  *  Description : Processes the WM_COMMAND message posted
  212.  *          by the Keys Help item of the Help menu
  213.  *
  214.  *  Concepts : Called from MainCommand when the Keys Help menu item
  215.  *           is selected.  Sends an HM_KEYS_HELP message to the
  216.  *           help instance so that the default Extended Help is
  217.  *           displayed.
  218.  *
  219.  *  API's : WinSendMsg
  220.  *
  221.  *  Parameters :  mp2 - Message parameter 2
  222.  *
  223.  *  Returns: None
  224.  *
  225.  ****************************************************************/
  226. VOID  HelpKeys(MPARAM mp2)
  227.  
  228. {
  229. /* this just displays the system keys help panel                  */
  230.   if (fHelpEnabled)
  231.   {
  232.     if ((BOOL)WinSendMsg(hwndHelpInstance, HM_KEYS_HELP, NULL, NULL))
  233.     {
  234.       MessageBox(hwndMain, IDMSG_HELPDISPLAYERROR, MB_OK | MB_ERROR, FALSE);
  235.     }
  236.   }
  237. /*
  238.  * This routine currently doesn't use the mp2 parameter but
  239.  * it is referenced here to prevent an 'Unreferenced Parameter'
  240.  * warning at compile time.
  241.  */
  242.   mp2;
  243. }   /*     End of HelpKeys()                              */
  244.  
  245. /*********************************************************************
  246.  *  Name: HelpIndex
  247.  *
  248.  *  Description : Processes the WM_COMMAND message posted
  249.  *          by the Index Help item of the Help menu
  250.  *
  251.  *  Concepts : Called from MainCommand when the Index Help menu item
  252.  *           is selected.  Sends an HM_INDEX_HELP message to the
  253.  *           help instance so that the default Extended Help is
  254.  *           displayed.
  255.  *
  256.  *  API's : WinSendMsg
  257.  *
  258.  *  Parameters :  mp2 - Message parameter 2
  259.  *
  260.  *  Returns: None
  261.  *
  262.  ****************************************************************/
  263. VOID  HelpIndex(MPARAM mp2)
  264. {
  265. /* this just displays the system help index panel                  */
  266.   if (fHelpEnabled)
  267.   {
  268.     if ((BOOL)WinSendMsg(hwndHelpInstance, HM_HELP_INDEX, NULL, NULL))
  269.     {
  270.        MessageBox(hwndMain, IDMSG_HELPDISPLAYERROR, MB_OK | MB_ERROR, FALSE);
  271.     }
  272.   }
  273.  /*
  274.   * This routine currently doesn't use the mp2 parameter but
  275.   * it is referenced here to prevent an 'Unreferenced Parameter'
  276.   * warning at compile time.
  277.  
  278.   */
  279.   mp2;
  280. }   /* End of HelpIndex()                              */
  281.  
  282. /*********************************************************************
  283.  *  Name: HelpProdInfo
  284.  *
  285.  *  Description : Processes the WM_COMMAND message posted
  286.  *          by the Index Help item of the Help menu
  287.  *
  288.  *  Concepts : Called from MainCommand when the Product
  289.  *           information Help menu item is selected.
  290.  *           Calls WinDlgBox to display the Product
  291.  *           Information dialog.
  292.  *
  293.  *  API's : WinDlgBox
  294.  *
  295.  *  Parameters :  mp2 - Message parameter 2
  296.  *
  297.  *  Returns: None
  298.  *
  299.  ****************************************************************/
  300. VOID  HelpProdInfo( MPARAM mp2)
  301. {
  302. /* display the Product Information dialog                      */
  303.   WinDlgBox(HWND_DESKTOP, hwndMain, (PFNWP)ProdInfoDlgProc, (HMODULE)0,
  304.         IDD_PRODINFO, (PVOID)NULL);
  305.  /*
  306.  
  307.   * This routine currently doesn't use the mp2 parameter but
  308.   * it is referenced here to prevent an 'Unreferenced Parameter'
  309.   * warning at compile time.
  310.   */
  311.     mp2;
  312.  
  313. }   /* End of HelpProdInfo()                              */
  314.  
  315. /*********************************************************************
  316.  *  Name: DisplayHelp
  317.  *
  318.  *  Description : Displays the help panel indicated
  319.  *
  320.  *  Concepts : Displays the help panel whose id is passed to
  321.  *           the routine.  Called whenever a help panel is
  322.  *           desired to be displayed, usually from the
  323.  *           WM_HELP processing of the dialog boxes.
  324.  *
  325.  *  API's : WinSendMsg
  326.  *
  327.  *  Parameters : idPanel - Id of the halp panel to be displayed
  328.  *
  329.  *  Returns: None
  330.  *
  331.  ****************************************************************/
  332. VOID DisplayHelpPanel(SHORT idPanel)
  333. {
  334.   if (fHelpEnabled)
  335.   {
  336.     if ((BOOL)WinSendMsg(hwndHelpInstance, HM_DISPLAY_HELP,
  337.         MPFROM2SHORT(idPanel, NULL), MPFROMSHORT(HM_RESOURCEID)))
  338.     {
  339.       MessageBox(hwndMainFrame, IDMSG_HELPDISPLAYERROR,
  340.          MB_OK | MB_ERROR, TRUE);
  341.     }
  342.   }
  343.  
  344. }   /*      End of DisplayHelpPanel()                      */
  345.  
  346. /*********************************************************************
  347.  *  Name: DestroyHelpInstance
  348.  *
  349.  *  Description : Destroys the help instance for the application
  350.  *
  351.  *  Concepts : Called after exit from message loop. Calls
  352.  
  353.  *           WinDestroyHelpInstance() to destroy the
  354.  *           help instance.
  355.  *
  356.  *  API's : WinDestroyHelpInstance
  357.  *
  358.  *  Parameters : None
  359.  
  360.  * None
  361.  *  Returns:
  362.  *
  363.  ****************************************************************/
  364. VOID DestroyHelpInstance(VOID)
  365. {
  366.   if ((BOOL)hwndHelpInstance)
  367.   {
  368.      WinDestroyHelpInstance(hwndHelpInstance);
  369.   }
  370.  
  371. }   /*          End of DestroyHelpInstance()                      */
  372.