xref: /reactos/base/applications/calc/htmlhelp.c (revision 019f21ee)
1 /*
2  * ReactOS Calc (HtmlHelp support)
3  *
4  * Copyright 2007-2017, Carlo Bramini
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #include "calc.h"
22 
23 #define GET_CB(name) \
24     calc_##name = (type_##name)GetProcAddress(hHtmlHelp, #name); \
25     if (calc_##name == NULL) calc_##name = dummy_##name;
26 
27 static HWND WINAPI
28 dummy_HtmlHelpA(HWND hWnd, LPCSTR pszFile, UINT uCommand, DWORD dwData);
29 
30 static HWND WINAPI
31 dummy_HtmlHelpW(HWND hWnd, LPCWSTR pszFile, UINT uCommand, DWORD dwData);
32 
33 type_HtmlHelpA calc_HtmlHelpA = dummy_HtmlHelpA;
34 type_HtmlHelpW calc_HtmlHelpW = dummy_HtmlHelpW;
35 
36 static HMODULE hHtmlHelp;
37 
38 static HWND WINAPI
39 dummy_HtmlHelpA(HWND hWnd, LPCSTR pszFile, UINT uCommand, DWORD dwData)
40 {
41     return NULL;
42 }
43 
44 static HWND WINAPI
45 dummy_HtmlHelpW(HWND hWnd, LPCWSTR pszFile, UINT uCommand, DWORD dwData)
46 {
47     return NULL;
48 }
49 
50 void HtmlHelp_Start(HINSTANCE hInstance)
51 {
52     hHtmlHelp = LoadLibrary(_T("HHCTRL.OCX"));
53     if (hHtmlHelp == NULL)
54         return;
55 
56     GET_CB(HtmlHelpW)
57     GET_CB(HtmlHelpA)
58 }
59 
60 void HtmlHelp_Stop(void)
61 {
62     if(hHtmlHelp == NULL)
63         return;
64 
65     FreeLibrary(hHtmlHelp);
66     hHtmlHelp = NULL;
67 }
68