2 * hhctrl implementation
4 * Copyright 2004 Krzysztof Foltman
6 * This library 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.1 of the License, or (at your option) any later version.
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.
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 St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
28 int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine);
30 HINSTANCE hhctrl_hinstance;
32 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
34 TRACE("(%p,%d,%p)\n", hInstance, fdwReason, lpvReserved);
38 case DLL_PROCESS_ATTACH:
39 hhctrl_hinstance = hInstance;
40 DisableThreadLibraryCalls(hInstance);
42 case DLL_PROCESS_DETACH:
48 static const char *command_to_string(UINT command)
50 #define X(x) case x: return #x
53 X( HH_DISPLAY_TOPIC );
55 X( HH_DISPLAY_INDEX );
56 X( HH_DISPLAY_SEARCH );
59 X( HH_GET_WIN_HANDLE );
60 X( HH_ENUM_INFO_TYPE );
61 X( HH_SET_INFO_TYPE );
66 X( HH_KEYWORD_LOOKUP );
67 X( HH_DISPLAY_TEXT_POPUP );
69 X( HH_TP_HELP_CONTEXTMENU );
70 X( HH_TP_HELP_WM_HELP );
73 X( HH_GET_LAST_ERROR );
74 X( HH_ENUM_CATEGORY );
75 X( HH_ENUM_CATEGORY_IT );
76 X( HH_RESET_IT_FILTER );
77 X( HH_SET_INCLUSIVE_FILTER );
78 X( HH_SET_EXCLUSIVE_FILTER );
81 X( HH_PRETRANSLATEMESSAGE );
82 X( HH_SET_GLOBAL_PROPERTY );
83 default: return "???";
88 HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
92 TRACE("(%p, %s, command=%s, data=%d)\n",
93 caller, debugstr_w( filename ),
94 command_to_string( command ), data);
98 DWORD len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
100 file = hhctrl_alloc(len);
101 WideCharToMultiByte( CP_ACP, 0, filename, -1, file, len, NULL, NULL );
106 case HH_DISPLAY_TOPIC:
108 case HH_DISPLAY_SEARCH:
109 case HH_HELP_CONTEXT:
110 FIXME("Not all HH cases handled correctly\n");
111 doWinMain(GetModuleHandleW(NULL), file);
114 FIXME("HH case %s not handled.\n", command_to_string( command ));
120 HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
127 DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
129 wfile = hhctrl_alloc(len*sizeof(WCHAR));
130 MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
133 result = HtmlHelpW( caller, wfile, command, data );
139 /******************************************************************
140 * doWinMain (hhctrl.ocx.13)
142 int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
146 LPWSTR filename = strdupAtoW(szCmdLine);
148 /* FIXME: Check szCmdLine for bad arguments */
149 info = CreateHelpViewer(filename);
150 hhctrl_free(filename);
154 NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszFile);
156 while (GetMessageW(&msg, 0, 0, 0))
158 TranslateMessage(&msg);
159 DispatchMessageW(&msg);
162 ReleaseHelpViewer(info);