source: trunk/helper.cpp@ 113

Last change on this file since 113 was 113, checked in by Gregg Young, 4 years ago

Minor code updates

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
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
24Helper :: Helper (HWND hwnd)
25{
26 HELPINIT helpInit;
27 PPIB ppib;
28 char *ptr;
29
30 // get the Process Information Block
31 DosGetInfoBlocks(0, &ppib);
32
33 // get a pointer to the environment
34 ptr = ppib->pib_pchenv;
35
36 // loop through the environment strings to find
37 // the null string that terminates it
38 while (*ptr)
39 ptr = strchr(ptr, 0) + 1;
40
41 // the exe's fully-qualified filename starts at the next character
42 ptr++;
43
44 // if we return because of an error, Help will be disabled
45 fHelpEnabled = TRUE;
46
47 // inititalize help init structure
48 helpInit.cb = sizeof (HELPINIT);
49 helpInit.ulReturnCode = 0L;
50 helpInit.pszTutorialName = PSZ (NULL);
51 helpInit.phtHelpTable = PHELPTABLE (MAKELONG (MAIN_HELP_TABLE,
52 0xFFFF));
53 helpInit.hmodHelpTableModule = GETMODULE;
54 helpInit.hmodAccelActionBarModule = GETMODULE;
55 helpInit.idAccelTable = 0;
56 helpInit.idActionBar = 0;
57#ifdef _QUIET_
58 helpInit.pszHelpWindowTitle = PSZ (PSZ_QNAMEVERSION);
59#else
60 helpInit.pszHelpWindowTitle = PSZ (PSZ_NAMEVERSION);
61#endif
62 helpInit.fShowPanelId = CMIC_HIDE_PANEL_ID;
63
64 CHAR fullExeName[CCHMAXPATH];
65 CHAR *p;;
66 strcpy(fullExeName, ptr);
67 p = strrchr(fullExeName, '\\');
68 if (p)
69 *p = 0;
70 CHAR ach[_MAX_FNAME+_MAX_EXT];
71 sprintf (ach, "%s\\%s.hlp", fullExeName, pset->QueryString (SEI_LANGUAGEHELP));
72 helpInit.pszHelpLibraryName = PSZ (ach);
73
74 // create the help instance
75 hwndHelpInstance = WinCreateHelpInstance (hab, &helpInit);
76 if (!hwndHelpInstance || helpInit.ulReturnCode)
77 {
78 DisplayError (RSTR (IDS_ERROR_HELPERHEADING),
79 RSTR (IDS_ERROR_COULDNOTINITHELPFILE), ach);
80 fHelpEnabled = FALSE;
81 }
82
83 // associate help instance with main frame
84 if (! WinAssociateHelpInstance (hwndHelpInstance, hwnd))
85 {
86 DisplayError (RSTR (IDS_ERROR_HELPERHEADING),
87 RSTR (IDS_ERROR_COULDNOTINITHELP));
88 fHelpEnabled = FALSE;
89 }
90}
91
92// ** ~Helper ************************************************************* /*FOLD00*/
93
94Helper :: ~Helper (VOID)
95{
96 if (hwndHelpInstance)
97 WinDestroyHelpInstance (hwndHelpInstance);
98}
99
100// ** DisplayPanel ******************************************************** /*FOLD00*/
101
102VOID Helper :: DisplayPanel (SHORT idPanel)
103{
104 if (fHelpEnabled)
105 {
106 WinPostMsg (hwndHelpInstance, HM_DISPLAY_HELP,
107 MPFROMSHORT (idPanel), MPFROMSHORT (HM_RESOURCEID));
108 }
109}
110
111#if 0
112VOID Helper :: ChangeActiveWindow (HWND hwnd)
113{
114 if (fHelpEnabled)
115 {
116 WinPostMsg (hwndHelpInstance, HM_SET_ACTIVE_WINDOW,
117 MPFROMHWND (hwnd), MPFROMHWND (NULL));
118 }
119}
120#endif
121// ************************************************************************
Note: See TracBrowser for help on using the repository browser.