2 * hhctrl implementation
4 * Copyright 2004 Krzysztof Foltman
5 * Copyright 2007 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp
);
29 HINSTANCE hhctrl_hinstance
;
30 BOOL hh_process
= FALSE
;
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_SAFE_DISPLAY_TOPIC
);
82 X( HH_PRETRANSLATEMESSAGE
);
83 X( HH_SET_GLOBAL_PROPERTY
);
84 default: return "???";
89 /******************************************************************
90 * HtmlHelpW (hhctrl.ocx.15)
92 HWND WINAPI
HtmlHelpW(HWND caller
, LPCWSTR filename
, UINT command
, DWORD_PTR data
)
94 TRACE("(%p, %s, command=%s, data=%lx)\n",
95 caller
, debugstr_w( filename
),
96 command_to_string( command
), data
);
100 case HH_DISPLAY_TOPIC
:
102 case HH_DISPLAY_SEARCH
:{
106 FIXME("Not all HH cases handled correctly\n");
108 info
= CreateHelpViewer(filename
);
112 res
= NavigateToChm(info
, info
->pCHMInfo
->szFile
, info
->WinType
.pszFile
);
114 ReleaseHelpViewer(info
);
117 return NULL
; /* FIXME */
119 case HH_HELP_CONTEXT
: {
123 info
= CreateHelpViewer(filename
);
127 url
= FindContextAlias(info
->pCHMInfo
, data
);
131 NavigateToUrl(info
, url
);
134 return NULL
; /* FIXME */
137 FIXME("HH case %s not handled.\n", command_to_string( command
));
143 /******************************************************************
144 * HtmlHelpA (hhctrl.ocx.14)
146 HWND WINAPI
HtmlHelpA(HWND caller
, LPCSTR filename
, UINT command
, DWORD_PTR data
)
148 WCHAR
*wfile
= NULL
, *wdata
= NULL
;
154 len
= MultiByteToWideChar( CP_ACP
, 0, filename
, -1, NULL
, 0 );
155 wfile
= hhctrl_alloc(len
*sizeof(WCHAR
));
156 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, wfile
, len
);
163 case HH_ALINK_LOOKUP
:
164 case HH_DISPLAY_SEARCH
:
165 case HH_DISPLAY_TEXT_POPUP
:
166 case HH_GET_LAST_ERROR
:
167 case HH_GET_WIN_TYPE
:
168 case HH_KEYWORD_LOOKUP
:
169 case HH_SET_WIN_TYPE
:
171 FIXME("structures not handled yet\n");
174 case HH_DISPLAY_INDEX
:
175 case HH_DISPLAY_TOPIC
:
177 case HH_GET_WIN_HANDLE
:
178 case HH_SAFE_DISPLAY_TOPIC
:
179 len
= MultiByteToWideChar( CP_ACP
, 0, (const char*)data
, -1, NULL
, 0 );
180 wdata
= hhctrl_alloc(len
*sizeof(WCHAR
));
181 MultiByteToWideChar( CP_ACP
, 0, (const char*)data
, -1, wdata
, len
);
185 case HH_HELP_CONTEXT
:
187 case HH_PRETRANSLATEMESSAGE
:
188 case HH_TP_HELP_CONTEXTMENU
:
189 case HH_TP_HELP_WM_HELP
:
190 case HH_UNINITIALIZE
:
191 /* either scalar or pointer to scalar - do nothing */
195 FIXME("Unknown command: %s (%d)\n", command_to_string(command
), command
);
200 result
= HtmlHelpW( caller
, wfile
, command
, wdata
? (DWORD_PTR
)wdata
: data
);
207 /******************************************************************
208 * doWinMain (hhctrl.ocx.13)
210 int WINAPI
doWinMain(HINSTANCE hInstance
, LPSTR szCmdLine
)
216 /* FIXME: Check szCmdLine for bad arguments */
217 HtmlHelpA(GetDesktopWindow(), szCmdLine
, HH_DISPLAY_TOPIC
, 0);
219 while (GetMessageW(&msg
, 0, 0, 0))
221 TranslateMessage(&msg
);
222 DispatchMessageW(&msg
);
228 /******************************************************************
229 * DllGetClassObject (hhctrl.ocx.@)
231 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
233 FIXME("(%s %s %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
234 return CLASS_E_CLASSNOTAVAILABLE
;