home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OHelp.cpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  4KB  |  147 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OHelp.cpp
  5.  
  6. // help for PM applications
  7.  
  8. /*
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  15.  *    endorse or promote products derived from this software
  16.  *    without specific prior written permission.
  17.  * 3. See OCL.INF for a detailed copyright notice.
  18.  *
  19.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  20.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29.  * SUCH DAMAGE.
  30.  */
  31.  
  32.  
  33. // $Header: W:/Projects/OCL/Source/rcs/OHelp.cpp 1.50 1996/08/11 23:49:17 B.STEIN Release $
  34.  
  35. #define __OCL_SOURCE__
  36.  
  37. #define OINCL_OSTRING
  38. #define OINCL_BASE
  39.  
  40. #include <ocl.hpp>
  41. #include <OHelp.hpp>
  42.  
  43.  
  44. OHelp::OHelp(const ULONG mainTable, const ULONG errorID)
  45.   : table(mainTable), 
  46.     errid(errorID), 
  47.     isHlpAvail(FALSE) 
  48.   {}
  49.  
  50.  
  51. OHelp::~OHelp() 
  52. {
  53.  terminateHelp(); 
  54. }
  55.  
  56.  
  57. PSZ OHelp::isOfType() const
  58.  return("OHelp"); 
  59. }
  60.  
  61.  
  62. OHelp& OHelp::terminateHelp()
  63. {
  64.  if (helpInstance)
  65.    WinDestroyHelpInstance(helpInstance);
  66.  return(*this);
  67. }
  68.  
  69.  
  70. OHelp& OHelp::initializeHelp(PSZ helpLibrary,
  71.                              PSZ title,
  72.                              const HWND associated)
  73. {
  74.  HELPINIT        HelpInit;
  75.  
  76.  if ((isHlpAvail) &&
  77.      (associated == assoc))
  78.     return(*this);
  79.  else
  80.     assoc = associated;
  81.  
  82.  HelpInit.cb                       = sizeof(HELPINIT);
  83.  HelpInit.ulReturnCode             = 0;
  84.  HelpInit.pszTutorialName          = (PSZ)NULL;
  85.  HelpInit.phtHelpTable             = (PHELPTABLE)MAKEULONG(table, 0xFFFF);
  86.  HelpInit.hmodHelpTableModule      = NULLHANDLE;
  87.  HelpInit.hmodAccelActionBarModule = NULLHANDLE;
  88.  HelpInit.idAccelTable             = 0;
  89.  HelpInit.idActionBar              = 0;
  90.  HelpInit.pszHelpWindowTitle       = title;
  91.  HelpInit.pszHelpLibraryName       = helpLibrary;
  92.  HelpInit.fShowPanelId             = 0;
  93.  
  94.  helpInstance = WinCreateHelpInstance(OApp::current().anchor(), &HelpInit);
  95.  
  96.  if ((!helpInstance) || (HelpInit.ulReturnCode))
  97.    throw OPMException(OCL::error(180), HelpInit.ulReturnCode);
  98.  
  99.  isHlpAvail = (BOOL) WinAssociateHelpInstance(helpInstance, associated);
  100.  
  101.  if(!isHlpAvail)
  102.    throw OPMException(OCL::error(181), 0);
  103.  
  104.  return(*this);
  105. }
  106.  
  107.  
  108.  
  109. OHelp& OHelp::helpRequest(const ULONG id)
  110. {
  111.  if(!isHlpAvail)
  112.    throw OPMException(OCL::error(182), 0);
  113.  
  114.  switch(id)
  115.    {
  116.     case help:
  117.       WinSendMsg(helpInstance, HM_DISPLAY_HELP, NULL, NULL);
  118.       break;
  119.  
  120.     case general:
  121.       WinSendMsg(helpInstance, HM_GENERAL_HELP, NULL, NULL);
  122.       break;
  123.  
  124.     case keys:
  125.       WinSendMsg(helpInstance, HM_KEYS_HELP, NULL, NULL);
  126.       break;
  127.  
  128.     case index:
  129.       WinSendMsg(helpInstance, HM_HELP_INDEX, NULL, NULL);
  130.       break;
  131.  
  132.     case contents:
  133.       WinSendMsg(helpInstance, HM_HELP_CONTENTS, NULL, NULL);
  134.       break;
  135.  
  136.     default:
  137.       WinSendMsg(helpInstance, HM_DISPLAY_HELP, MPFROMSHORT(id), HM_RESOURCEID);
  138.       break;
  139.    }
  140.  
  141.  return(*this);
  142. }
  143.  
  144.  
  145. // end of source
  146.