home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / videotlk.zip / SAMPLES / EX1 / HELPFUNC.C < prev    next >
Text File  |  1995-08-31  |  6KB  |  192 lines

  1.  
  2. /*------------------------------------------------------------------*
  3.  *                                                                  *
  4.  *  Video Toolkit For OS/2 Version 1.0                              *
  5.  *  Example Application No. 1                                       *
  6.  *  Written by Stephen Sloan.                                       *
  7.  *  Date : 22/02/95.                                                *
  8.  *  Copyright (c) Abbotsbury Software Ltd., United Kingdom. 1995.   *
  9.  *                                                                  *
  10.  *  Filename : helpfunc.c                                           *
  11.  *                                                                  *
  12.  *------------------------------------------------------------------*/
  13.  
  14. #define INCL_PM
  15.  
  16. #include <os2.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include "helpfunc.h"
  21.  
  22. extern  HWND    HwndFrame;
  23.  
  24. extern  void    msg_box (UCHAR *txt, UCHAR *title, ULONG options);
  25.  
  26. HAB     hab;
  27. char    szTitle[MESSAGELEN];
  28.  
  29. static  UCHAR   *Copyright =
  30.   "Copyright (c) Abbotsbury Software Ltd., UK. 1994-1995. All Rights Reserved";
  31. static HWND hwndHelpInstance;
  32. static CHAR szLibName[HELPLIBRARYNAMELEN];
  33. static CHAR szWindowTitle[HELPLIBRARYNAMELEN];
  34. static BOOL fHelpEnabled = FALSE;
  35.  
  36. void HelpInit (HWND hwnd)
  37. {
  38.     HELPINIT    hini;
  39.  
  40.         hab = WinQueryAnchorBlock (HwndFrame);
  41.         WinLoadString(hab, 0, IDS_TITLEBAR, sizeof (szTitle), szTitle);
  42.  
  43.         fHelpEnabled = FALSE;
  44.  
  45.         hini.cb = sizeof (HELPINIT);
  46.         hini.ulReturnCode = 0L;
  47.  
  48.         hini.pszTutorialName = (PSZ)NULL;
  49.  
  50.         hini.phtHelpTable = (PHELPTABLE)MAKELONG (HELP_TABLE, 0xFFFF);
  51.         hini.hmodHelpTableModule = (HMODULE)0;
  52.         hini.hmodAccelActionBarModule = (HMODULE)0;
  53.         hini.idAccelTable = 0;
  54.         hini.idActionBar = 0;
  55.  
  56.         if (!WinLoadString (hab,
  57.                             (HMODULE)0,
  58.                             IDS_HELPWINDOWTITLE,
  59.                             HELPLIBRARYNAMELEN,
  60.                             (PSZ)szWindowTitle))
  61.         {
  62.             msg_box ("Error loading window title",
  63.                      "Error", MB_OK | MB_ERROR);
  64.             return;
  65.         }
  66.  
  67.         hini.pszHelpWindowTitle = (PSZ)szWindowTitle;
  68.  
  69.         if (!WinLoadString (hab,
  70.                             (HMODULE)0,
  71.                             IDS_HELPLIBRARYNAME,
  72.                             HELPLIBRARYNAMELEN,
  73.                             (PSZ)szLibName))
  74.         {
  75.             msg_box ("Error loading library name",
  76.                      "Error", MB_OK | MB_ERROR);
  77.             return;
  78.         }
  79.  
  80.         hini.pszHelpLibraryName = (PSZ)szLibName;
  81.  
  82.         hwndHelpInstance = WinCreateHelpInstance (hab, &hini);
  83.  
  84.         if (!hwndHelpInstance || hini.ulReturnCode)
  85.         {
  86.             msg_box ("Error creating help instance",
  87.                      "Error", MB_OK | MB_ERROR);
  88.             return;
  89.         }
  90.  
  91.         if (!WinAssociateHelpInstance (hwndHelpInstance, hwnd))
  92.         {
  93.             msg_box ("Error associating help instance",
  94.                      "Error", MB_OK | MB_ERROR);
  95.             return;
  96.         }
  97.  
  98.         fHelpEnabled = TRUE;
  99. }
  100.  
  101.  
  102. void HelpHelpForHelp ()
  103. {
  104.         if (fHelpEnabled)
  105.         {
  106.             if (WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, NULL, NULL))
  107.             {
  108.                 msg_box ("Error displaying help panel",
  109.                          "Error", MB_OK | MB_ERROR);
  110.             }
  111.         }
  112. }
  113.  
  114.  
  115. void HelpExtended ()
  116. {
  117.         if (fHelpEnabled)
  118.         {
  119.             if (WinSendMsg (hwndHelpInstance, HM_EXT_HELP, NULL, NULL))
  120.             {
  121.                 msg_box ("Error displaying extended help panel",
  122.                          "Error", MB_OK | MB_ERROR);
  123.             }
  124.         }
  125. }
  126.  
  127. void HelpKeys ()
  128. {
  129.         if (fHelpEnabled)
  130.         {
  131.             if (WinSendMsg (hwndHelpInstance, HM_KEYS_HELP, NULL, NULL))
  132.             {
  133.                 msg_box ("Error displaying keys help panel",
  134.                          "Error", MB_OK | MB_ERROR);
  135.             }
  136.         }
  137. }
  138.  
  139. void HelpIndex ()
  140. {
  141.         if (fHelpEnabled)
  142.         {
  143.             if (WinSendMsg (hwndHelpInstance, HM_HELP_INDEX, NULL, NULL))
  144.             {
  145.                 msg_box ("Error displaying index help panel",
  146.                          "Error", MB_OK | MB_ERROR);
  147.             }
  148.         }
  149. }
  150.  
  151. void HelpContents ()
  152. {
  153.         if (fHelpEnabled)
  154.         {
  155.             if (WinSendMsg (hwndHelpInstance, HM_HELP_CONTENTS, NULL, NULL))
  156.             {
  157.                 msg_box ("Error displaying contents help panel",
  158.                          "Error", MB_OK | MB_ERROR);
  159.             }
  160.         }
  161. }
  162.  
  163. void HelpAbout ()
  164. {
  165.         WinDlgBox (HWND_DESKTOP,
  166.                    HwndFrame,
  167.                    (PFNWP)AboutDlgProc,
  168.                    (HMODULE)NULLHANDLE,
  169.                    IDD_PRODUCTINFO,
  170.                    NULL);
  171.         WinInvalidateRegion (HwndFrame, NULLHANDLE, FALSE);
  172. }
  173.  
  174. void DisplayHelpPanel (SHORT idPanel)
  175. {
  176.         if (fHelpEnabled)
  177.         {
  178.             if (WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
  179.                 MPFROM2SHORT (idPanel, NULL), MPFROMSHORT (HM_RESOURCEID)))
  180.             {
  181.                 msg_box ("Error displaying help panel",
  182.                          "Error", MB_OK | MB_ERROR);
  183.             }
  184.         }
  185. }
  186.  
  187. void DestroyHelpInstance ()
  188. {
  189.         if (hwndHelpInstance)
  190.             WinDestroyHelpInstance (hwndHelpInstance);
  191. }
  192.