Windows: Update fs newcell and add VIOCNEWCELL2
[openafs.git] / src / WINNT / afsapplib / al_help.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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  */
9
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include <WINNT/afsapplib.h>
16
17
18 /*
19  * DEFINITIONS ______________________________________________________________
20  *
21  */
22
23 typedef struct 
24    {
25    BOOL fInUse;
26    int idd;
27    DWORD *adwContext;
28    int idhOverview;
29    } DIALOGHELP, *LPDIALOGHELP;
30
31
32 /*
33  * VARIABLES ________________________________________________________________
34  *
35  */
36
37 static TCHAR g_szHelpfile[ MAX_PATH ] = TEXT("");
38
39 static DIALOGHELP *g_adh = NULL;
40 static size_t g_cdh = 0;
41
42
43 /*
44  * ROUTINES _________________________________________________________________
45  *
46  */
47
48 void AfsAppLib_RegisterHelpFile (LPTSTR pszFilename)
49 {
50    if (pszFilename)
51       lstrcpy (g_szHelpfile, pszFilename);
52    else
53       g_szHelpfile[0] = TEXT('\0');
54 }
55
56
57 void AfsAppLib_RegisterHelp (int idd, DWORD *adwContext, int idhOverview)
58 {
59    size_t ih;
60    for (ih = 0; ih < g_cdh; ++ih)
61       {
62       if (!g_adh[ ih ].fInUse)
63          continue;
64       if (g_adh[ ih ].idd == idd)
65          {
66          g_adh[ ih ].adwContext = adwContext;
67          g_adh[ ih ].idhOverview = idhOverview;
68          return;
69          }
70       }
71    for (ih = 0; ih < g_cdh; ++ih)
72       {
73       if (!g_adh[ ih ].fInUse)
74          break;
75       }
76    if (ih == g_cdh)
77       {
78       (void)REALLOC (g_adh, g_cdh, 1+ih, 16);
79       }
80    if (ih < g_cdh)
81       {
82       g_adh[ ih ].fInUse = TRUE;
83       g_adh[ ih ].idd = idd;
84       g_adh[ ih ].adwContext = adwContext;
85       g_adh[ ih ].idhOverview = idhOverview;
86       }
87 }
88
89
90 BOOL AfsAppLib_HandleHelp (int idd, HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
91 {
92    BOOL rc = FALSE;
93    size_t ih;
94
95    switch (msg)
96       {
97       case WM_COMMAND:
98          switch (LOWORD(wp))
99             {
100             case IDHELP:
101                for (ih = 0; ih < g_cdh; ++ih)
102                   {
103                   if (idd == g_adh[ ih ].idd)
104                      break;
105                   }
106                if (ih < g_cdh)
107                   {
108                   if (g_szHelpfile)
109                      WinHelp (hDlg, g_szHelpfile, HELP_CONTEXT, g_adh[ ih ].idhOverview);
110                   rc = TRUE;
111                   }
112                break;
113             }
114          break;
115
116       case WM_HELP:
117          LPHELPINFO lphi;
118          for (ih = 0; ih < g_cdh; ++ih)
119             {
120             if (idd == g_adh[ ih ].idd)
121                break;
122             }
123
124          if ( (ih == g_cdh) ||
125               ((lphi = (LPHELPINFO)lp) == NULL) ||
126               (lphi->hItemHandle == NULL) ||
127               (lphi->hItemHandle == hDlg) )
128             {
129             PostMessage (hDlg, WM_COMMAND, (WPARAM)MAKELONG(IDHELP,BN_CLICKED), (LPARAM)GetDlgItem (hDlg, IDHELP));
130             }
131          else
132             {
133             if (g_szHelpfile)
134                WinHelp ((HWND)(lphi->hItemHandle), g_szHelpfile, HELP_WM_HELP, (DWORD)(DWORD_PTR)g_adh[ ih ].adwContext);
135             }
136
137          rc = TRUE;
138          break;
139       }
140
141    return rc;
142 }
143