Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afsapplib / al_help.cpp
blob47e523420def8d98ace403841593c066ce379dac
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
15 #include <WINNT/afsapplib.h>
19 * DEFINITIONS ______________________________________________________________
23 typedef struct
25 BOOL fInUse;
26 int idd;
27 DWORD *adwContext;
28 int idhOverview;
29 } DIALOGHELP, *LPDIALOGHELP;
33 * VARIABLES ________________________________________________________________
37 static TCHAR g_szHelpfile[ MAX_PATH ] = TEXT("");
39 static DIALOGHELP *g_adh = NULL;
40 static size_t g_cdh = 0;
44 * ROUTINES _________________________________________________________________
48 void AfsAppLib_RegisterHelpFile (LPTSTR pszFilename)
50 if (pszFilename)
51 lstrcpy (g_szHelpfile, pszFilename);
52 else
53 g_szHelpfile[0] = TEXT('\0');
57 void AfsAppLib_RegisterHelp (int idd, DWORD *adwContext, int idhOverview)
59 size_t ih;
60 for (ih = 0; ih < g_cdh; ++ih)
62 if (!g_adh[ ih ].fInUse)
63 continue;
64 if (g_adh[ ih ].idd == idd)
66 g_adh[ ih ].adwContext = adwContext;
67 g_adh[ ih ].idhOverview = idhOverview;
68 return;
71 for (ih = 0; ih < g_cdh; ++ih)
73 if (!g_adh[ ih ].fInUse)
74 break;
76 if (ih == g_cdh)
78 (void)REALLOC (g_adh, g_cdh, 1+ih, 16);
80 if (ih < g_cdh)
82 g_adh[ ih ].fInUse = TRUE;
83 g_adh[ ih ].idd = idd;
84 g_adh[ ih ].adwContext = adwContext;
85 g_adh[ ih ].idhOverview = idhOverview;
90 BOOL AfsAppLib_HandleHelp (int idd, HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
92 BOOL rc = FALSE;
93 size_t ih;
95 switch (msg)
97 case WM_COMMAND:
98 switch (LOWORD(wp))
100 case IDHELP:
101 for (ih = 0; ih < g_cdh; ++ih)
103 if (idd == g_adh[ ih ].idd)
104 break;
106 if (ih < g_cdh)
108 if (g_szHelpfile)
109 WinHelp (hDlg, g_szHelpfile, HELP_CONTEXT, g_adh[ ih ].idhOverview);
110 rc = TRUE;
112 break;
114 break;
116 case WM_HELP:
117 LPHELPINFO lphi;
118 for (ih = 0; ih < g_cdh; ++ih)
120 if (idd == g_adh[ ih ].idd)
121 break;
124 if ( (ih == g_cdh) ||
125 ((lphi = (LPHELPINFO)lp) == NULL) ||
126 (lphi->hItemHandle == NULL) ||
127 (lphi->hItemHandle == hDlg) )
129 PostMessage (hDlg, WM_COMMAND, (WPARAM)MAKELONG(IDHELP,BN_CLICKED), (LPARAM)GetDlgItem (hDlg, IDHELP));
131 else
133 if (g_szHelpfile)
134 WinHelp ((HWND)(lphi->hItemHandle), g_szHelpfile, HELP_WM_HELP, (DWORD)(DWORD_PTR)g_adh[ ih ].adwContext);
137 rc = TRUE;
138 break;
141 return rc;