2004-04-22 03:45:00 +00:00
|
|
|
/*
|
|
|
|
* hhctrl implementation
|
|
|
|
*
|
|
|
|
* Copyright 2004 Krzysztof Foltman
|
2007-02-28 02:55:39 +00:00
|
|
|
* Copyright 2007 Jacek Caban for CodeWeavers
|
2004-04-22 03:45:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-22 03:45:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2007-02-22 21:45:16 +00:00
|
|
|
|
|
|
|
#define INIT_GUID
|
|
|
|
#include "hhctrl.h"
|
2004-04-22 03:45:00 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
|
|
|
|
|
2007-02-22 21:48:35 +00:00
|
|
|
HINSTANCE hhctrl_hinstance;
|
2007-02-28 02:55:39 +00:00
|
|
|
BOOL hh_process = FALSE;
|
2007-02-22 21:48:35 +00:00
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%d,%p)\n", hInstance, fdwReason, lpvReserved);
|
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
hhctrl_hinstance = hInstance;
|
|
|
|
DisableThreadLibraryCalls(hInstance);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-04-16 10:47:46 +00:00
|
|
|
static const char *command_to_string(UINT command)
|
|
|
|
{
|
|
|
|
#define X(x) case x: return #x
|
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
X( HH_DISPLAY_TOPIC );
|
|
|
|
X( HH_DISPLAY_TOC );
|
|
|
|
X( HH_DISPLAY_INDEX );
|
|
|
|
X( HH_DISPLAY_SEARCH );
|
|
|
|
X( HH_SET_WIN_TYPE );
|
|
|
|
X( HH_GET_WIN_TYPE );
|
|
|
|
X( HH_GET_WIN_HANDLE );
|
|
|
|
X( HH_ENUM_INFO_TYPE );
|
|
|
|
X( HH_SET_INFO_TYPE );
|
|
|
|
X( HH_SYNC );
|
|
|
|
X( HH_RESERVED1 );
|
|
|
|
X( HH_RESERVED2 );
|
|
|
|
X( HH_RESERVED3 );
|
|
|
|
X( HH_KEYWORD_LOOKUP );
|
|
|
|
X( HH_DISPLAY_TEXT_POPUP );
|
|
|
|
X( HH_HELP_CONTEXT );
|
|
|
|
X( HH_TP_HELP_CONTEXTMENU );
|
|
|
|
X( HH_TP_HELP_WM_HELP );
|
|
|
|
X( HH_CLOSE_ALL );
|
|
|
|
X( HH_ALINK_LOOKUP );
|
|
|
|
X( HH_GET_LAST_ERROR );
|
|
|
|
X( HH_ENUM_CATEGORY );
|
|
|
|
X( HH_ENUM_CATEGORY_IT );
|
|
|
|
X( HH_RESET_IT_FILTER );
|
|
|
|
X( HH_SET_INCLUSIVE_FILTER );
|
|
|
|
X( HH_SET_EXCLUSIVE_FILTER );
|
|
|
|
X( HH_INITIALIZE );
|
|
|
|
X( HH_UNINITIALIZE );
|
2007-05-02 16:15:58 +00:00
|
|
|
X( HH_SAFE_DISPLAY_TOPIC );
|
2005-04-16 10:47:46 +00:00
|
|
|
X( HH_PRETRANSLATEMESSAGE );
|
|
|
|
X( HH_SET_GLOBAL_PROPERTY );
|
|
|
|
default: return "???";
|
|
|
|
}
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2007-02-28 02:55:39 +00:00
|
|
|
/******************************************************************
|
2007-06-12 15:50:32 +00:00
|
|
|
* HtmlHelpW (HHCTRL.OCX.15)
|
2007-02-28 02:55:39 +00:00
|
|
|
*/
|
2007-05-02 16:15:58 +00:00
|
|
|
HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR data)
|
2004-04-22 03:45:00 +00:00
|
|
|
{
|
2007-05-02 16:15:58 +00:00
|
|
|
TRACE("(%p, %s, command=%s, data=%lx)\n",
|
2005-04-16 10:47:46 +00:00
|
|
|
caller, debugstr_w( filename ),
|
|
|
|
command_to_string( command ), data);
|
2004-06-01 19:44:59 +00:00
|
|
|
|
2007-02-28 02:53:37 +00:00
|
|
|
switch (command)
|
2005-11-04 11:15:01 +00:00
|
|
|
{
|
2007-02-28 02:53:37 +00:00
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
2007-02-28 02:55:39 +00:00
|
|
|
case HH_DISPLAY_SEARCH:{
|
2007-05-02 16:16:59 +00:00
|
|
|
static const WCHAR delimW[] = {':',':',0};
|
2007-02-28 02:53:37 +00:00
|
|
|
HHInfo *info;
|
|
|
|
BOOL res;
|
2007-05-02 16:16:59 +00:00
|
|
|
WCHAR chm_file[MAX_PATH];
|
|
|
|
const WCHAR *index;
|
2005-11-04 11:15:01 +00:00
|
|
|
|
2007-02-28 02:53:37 +00:00
|
|
|
FIXME("Not all HH cases handled correctly\n");
|
2005-11-04 11:15:01 +00:00
|
|
|
|
2007-05-02 16:16:59 +00:00
|
|
|
index = strstrW(filename, delimW);
|
|
|
|
if (index)
|
|
|
|
{
|
|
|
|
memcpy(chm_file, filename, (index-filename)*sizeof(WCHAR));
|
|
|
|
chm_file[index-filename] = 0;
|
|
|
|
filename = chm_file;
|
2008-03-25 20:55:07 +00:00
|
|
|
index += 2; /* advance beyond "::" for calling NavigateToChm() later */
|
2007-05-02 16:16:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (command!=HH_DISPLAY_SEARCH) /* FIXME - use HH_FTS_QUERYW structure in data */
|
|
|
|
index = (const WCHAR*)data;
|
|
|
|
}
|
|
|
|
|
2007-02-28 02:53:37 +00:00
|
|
|
info = CreateHelpViewer(filename);
|
|
|
|
|
2007-05-02 16:16:32 +00:00
|
|
|
if (info)
|
|
|
|
{
|
2007-05-02 16:16:59 +00:00
|
|
|
if (!index)
|
|
|
|
index = info->WinType.pszFile;
|
|
|
|
res = NavigateToChm(info, info->pCHMInfo->szFile, index);
|
2007-05-02 16:16:32 +00:00
|
|
|
if(!res)
|
|
|
|
ReleaseHelpViewer(info);
|
|
|
|
}
|
2007-02-28 02:53:37 +00:00
|
|
|
|
|
|
|
return NULL; /* FIXME */
|
2005-04-16 10:47:46 +00:00
|
|
|
}
|
2007-02-28 02:55:39 +00:00
|
|
|
case HH_HELP_CONTEXT: {
|
|
|
|
HHInfo *info;
|
|
|
|
LPWSTR url;
|
|
|
|
|
|
|
|
info = CreateHelpViewer(filename);
|
|
|
|
if(!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
url = FindContextAlias(info->pCHMInfo, data);
|
|
|
|
if(!url)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
NavigateToUrl(info, url);
|
2007-12-09 15:29:44 +00:00
|
|
|
heap_free(url);
|
2007-02-28 02:55:39 +00:00
|
|
|
|
|
|
|
return NULL; /* FIXME */
|
|
|
|
}
|
2007-10-15 18:19:56 +00:00
|
|
|
case HH_PRETRANSLATEMESSAGE: {
|
|
|
|
static BOOL warned = FALSE;
|
|
|
|
|
|
|
|
if (!warned)
|
|
|
|
{
|
|
|
|
FIXME("HH_PRETRANSLATEMESSAGE unimplemented\n");
|
|
|
|
warned = TRUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-28 02:53:37 +00:00
|
|
|
default:
|
|
|
|
FIXME("HH case %s not handled.\n", command_to_string( command ));
|
|
|
|
}
|
|
|
|
|
2005-11-07 11:08:47 +00:00
|
|
|
return 0;
|
2004-04-22 03:45:00 +00:00
|
|
|
}
|
|
|
|
|
2007-02-28 02:55:39 +00:00
|
|
|
/******************************************************************
|
2007-06-12 15:50:32 +00:00
|
|
|
* HtmlHelpA (HHCTRL.OCX.14)
|
2007-02-28 02:55:39 +00:00
|
|
|
*/
|
2007-05-02 16:15:58 +00:00
|
|
|
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data)
|
2004-04-22 03:45:00 +00:00
|
|
|
{
|
2007-05-02 16:15:58 +00:00
|
|
|
WCHAR *wfile = NULL, *wdata = NULL;
|
|
|
|
DWORD len;
|
2004-06-01 19:44:59 +00:00
|
|
|
HWND result;
|
|
|
|
|
2005-04-11 12:47:40 +00:00
|
|
|
if (filename)
|
|
|
|
{
|
2007-05-02 16:15:58 +00:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
|
2007-12-09 15:29:44 +00:00
|
|
|
wfile = heap_alloc(len*sizeof(WCHAR));
|
2005-04-11 12:47:40 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
|
|
|
|
}
|
2005-04-16 10:47:46 +00:00
|
|
|
|
2007-05-02 16:15:58 +00:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
switch(command)
|
|
|
|
{
|
|
|
|
case HH_ALINK_LOOKUP:
|
|
|
|
case HH_DISPLAY_SEARCH:
|
|
|
|
case HH_DISPLAY_TEXT_POPUP:
|
|
|
|
case HH_GET_LAST_ERROR:
|
|
|
|
case HH_GET_WIN_TYPE:
|
|
|
|
case HH_KEYWORD_LOOKUP:
|
|
|
|
case HH_SET_WIN_TYPE:
|
|
|
|
case HH_SYNC:
|
|
|
|
FIXME("structures not handled yet\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HH_DISPLAY_INDEX:
|
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
|
|
|
case HH_GET_WIN_HANDLE:
|
|
|
|
case HH_SAFE_DISPLAY_TOPIC:
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, (const char*)data, -1, NULL, 0 );
|
2007-12-09 15:29:44 +00:00
|
|
|
wdata = heap_alloc(len*sizeof(WCHAR));
|
2007-05-02 16:15:58 +00:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, (const char*)data, -1, wdata, len );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HH_CLOSE_ALL:
|
|
|
|
case HH_HELP_CONTEXT:
|
|
|
|
case HH_INITIALIZE:
|
|
|
|
case HH_PRETRANSLATEMESSAGE:
|
|
|
|
case HH_TP_HELP_CONTEXTMENU:
|
|
|
|
case HH_TP_HELP_WM_HELP:
|
|
|
|
case HH_UNINITIALIZE:
|
|
|
|
/* either scalar or pointer to scalar - do nothing */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unknown command: %s (%d)\n", command_to_string(command), command);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = HtmlHelpW( caller, wfile, command, wdata ? (DWORD_PTR)wdata : data );
|
2004-06-01 19:44:59 +00:00
|
|
|
|
2007-12-09 15:29:44 +00:00
|
|
|
heap_free(wfile);
|
|
|
|
heap_free(wdata);
|
2004-06-01 19:44:59 +00:00
|
|
|
return result;
|
2004-04-22 03:45:00 +00:00
|
|
|
}
|
2007-02-28 02:49:20 +00:00
|
|
|
|
|
|
|
/******************************************************************
|
2007-06-12 15:50:32 +00:00
|
|
|
* doWinMain (HHCTRL.OCX.13)
|
2007-02-28 02:49:20 +00:00
|
|
|
*/
|
|
|
|
int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
2007-02-28 02:54:25 +00:00
|
|
|
hh_process = TRUE;
|
|
|
|
|
2007-02-28 02:49:20 +00:00
|
|
|
/* FIXME: Check szCmdLine for bad arguments */
|
2007-02-28 02:55:00 +00:00
|
|
|
HtmlHelpA(GetDesktopWindow(), szCmdLine, HH_DISPLAY_TOPIC, 0);
|
2007-02-28 02:49:20 +00:00
|
|
|
|
|
|
|
while (GetMessageW(&msg, 0, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-28 02:51:04 +00:00
|
|
|
|
|
|
|
/******************************************************************
|
2007-06-12 15:50:32 +00:00
|
|
|
* DllGetClassObject (HHCTRL.OCX.@)
|
2007-02-28 02:51:04 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
FIXME("(%s %s %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|