| 1 | /***
 | 
|---|
| 2 |  This file belongs to the Gotcha! distribution.
 | 
|---|
| 3 |  Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
 | 
|---|
| 4 | 
 | 
|---|
| 5 |  This program is free software; you can redistribute it and/or modify
 | 
|---|
| 6 |  it under the terms of the GNU General Public License as published by
 | 
|---|
| 7 |  the Free Software Foundation; either version 2 of the License, or
 | 
|---|
| 8 |  (at your option) any later version.
 | 
|---|
| 9 | 
 | 
|---|
| 10 |  This program is distributed in the hope that it will be useful,
 | 
|---|
| 11 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 12 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 13 |  GNU General Public License for more details.
 | 
|---|
| 14 | 
 | 
|---|
| 15 |  You should have received a copy of the GNU General Public License
 | 
|---|
| 16 |  along with this program; if not, write to the Free Software
 | 
|---|
| 17 |  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|---|
| 18 |  ***/
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "helper.h"
 | 
|---|
| 21 | 
 | 
|---|
| 22 | // ** Helper ************************************************************** /*FOLD00*/
 | 
|---|
| 23 | 
 | 
|---|
| 24 | Helper :: Helper (HWND hwnd)
 | 
|---|
| 25 | {
 | 
|---|
| 26 |     HELPINIT   helpInit;
 | 
|---|
| 27 | 
 | 
|---|
| 28 |     // if we return because of an error, Help will be disabled
 | 
|---|
| 29 |     fHelpEnabled = TRUE;
 | 
|---|
| 30 | 
 | 
|---|
| 31 |     // inititalize help init structure
 | 
|---|
| 32 |     helpInit.cb                  = sizeof (HELPINIT);
 | 
|---|
| 33 |     helpInit.ulReturnCode        = 0L;
 | 
|---|
| 34 |     helpInit.pszTutorialName     = PSZ (NULL);
 | 
|---|
| 35 |     helpInit.phtHelpTable        = PHELPTABLE (MAKELONG (MAIN_HELP_TABLE,
 | 
|---|
| 36 |                                                          0xFFFF));
 | 
|---|
| 37 |     helpInit.hmodHelpTableModule = GETMODULE;
 | 
|---|
| 38 |     helpInit.hmodAccelActionBarModule = GETMODULE;
 | 
|---|
| 39 |     helpInit.idAccelTable        = 0;
 | 
|---|
| 40 |     helpInit.idActionBar         = 0;
 | 
|---|
| 41 | #ifdef _QUIET_
 | 
|---|
| 42 |     helpInit.pszHelpWindowTitle  = PSZ (PSZ_QNAMEVERSION);
 | 
|---|
| 43 | #else
 | 
|---|
| 44 |     helpInit.pszHelpWindowTitle  = PSZ (PSZ_NAMEVERSION);
 | 
|---|
| 45 | #endif
 | 
|---|
| 46 |     helpInit.fShowPanelId        = CMIC_HIDE_PANEL_ID;
 | 
|---|
| 47 | 
 | 
|---|
| 48 |     CHAR   ach[_MAX_FNAME+_MAX_EXT];
 | 
|---|
| 49 |     sprintf (ach, "%s.hlp", pset->QueryString (SEI_LANGUAGEHELP));
 | 
|---|
| 50 |     helpInit.pszHelpLibraryName  = PSZ (ach);
 | 
|---|
| 51 | 
 | 
|---|
| 52 |     // create the help instance
 | 
|---|
| 53 |     hwndHelpInstance = WinCreateHelpInstance (hab, &helpInit);
 | 
|---|
| 54 |     if (!hwndHelpInstance || helpInit.ulReturnCode)
 | 
|---|
| 55 |     {
 | 
|---|
| 56 |         DisplayError (RSTR (IDS_ERROR_HELPERHEADING),
 | 
|---|
| 57 |                       RSTR (IDS_ERROR_COULDNOTINITHELPFILE), ach);
 | 
|---|
| 58 |         fHelpEnabled = FALSE;
 | 
|---|
| 59 |     }
 | 
|---|
| 60 | 
 | 
|---|
| 61 |     // associate help instance with main frame
 | 
|---|
| 62 |     if (! WinAssociateHelpInstance (hwndHelpInstance, hwnd))
 | 
|---|
| 63 |     {
 | 
|---|
| 64 |         DisplayError (RSTR (IDS_ERROR_HELPERHEADING),
 | 
|---|
| 65 |                       RSTR (IDS_ERROR_COULDNOTINITHELP));
 | 
|---|
| 66 |         fHelpEnabled = FALSE;
 | 
|---|
| 67 |     }
 | 
|---|
| 68 | }
 | 
|---|
| 69 | 
 | 
|---|
| 70 | // ** ~Helper ************************************************************* /*FOLD00*/
 | 
|---|
| 71 | 
 | 
|---|
| 72 | Helper :: ~Helper (VOID)
 | 
|---|
| 73 | {
 | 
|---|
| 74 |     if (hwndHelpInstance)
 | 
|---|
| 75 |         WinDestroyHelpInstance (hwndHelpInstance);
 | 
|---|
| 76 | }
 | 
|---|
| 77 | 
 | 
|---|
| 78 | // ** DisplayPanel ******************************************************** /*FOLD00*/
 | 
|---|
| 79 | 
 | 
|---|
| 80 | VOID Helper :: DisplayPanel (SHORT idPanel)
 | 
|---|
| 81 | {
 | 
|---|
| 82 |     if (fHelpEnabled)
 | 
|---|
| 83 |     {
 | 
|---|
| 84 |         WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
 | 
|---|
| 85 |                     MPFROM2SHORT (idPanel, NULL), MPFROMSHORT (HM_RESOURCEID));
 | 
|---|
| 86 |     }
 | 
|---|
| 87 | }
 | 
|---|
| 88 | 
 | 
|---|
| 89 | // ************************************************************************
 | 
|---|