2004-04-22 05:45:00 +02:00
|
|
|
/*
|
|
|
|
* hhctrl implementation
|
|
|
|
*
|
|
|
|
* Copyright 2004 Krzysztof Foltman
|
|
|
|
*
|
|
|
|
* 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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-22 05:45:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2007-02-22 22:45:16 +01:00
|
|
|
|
|
|
|
#define INIT_GUID
|
|
|
|
#include "hhctrl.h"
|
2004-04-22 05:45:00 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
|
|
|
|
|
2005-11-04 12:15:01 +01:00
|
|
|
int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine);
|
|
|
|
|
2007-02-22 22:48:35 +01:00
|
|
|
HINSTANCE hhctrl_hinstance;
|
|
|
|
|
|
|
|
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 12:47:46 +02: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 );
|
|
|
|
X( HH_PRETRANSLATEMESSAGE );
|
|
|
|
X( HH_SET_GLOBAL_PROPERTY );
|
|
|
|
default: return "???";
|
|
|
|
}
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2004-06-01 21:44:59 +02:00
|
|
|
HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
|
2004-04-22 05:45:00 +02:00
|
|
|
{
|
2005-11-04 12:15:01 +01:00
|
|
|
CHAR *file = NULL;
|
|
|
|
|
2006-10-03 23:38:59 +02:00
|
|
|
TRACE("(%p, %s, command=%s, data=%d)\n",
|
2005-04-16 12:47:46 +02:00
|
|
|
caller, debugstr_w( filename ),
|
|
|
|
command_to_string( command ), data);
|
2004-06-01 21:44:59 +02:00
|
|
|
|
2005-11-04 12:15:01 +01:00
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
DWORD len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
|
|
|
|
|
2007-02-22 22:49:13 +01:00
|
|
|
file = hhctrl_alloc(len);
|
2005-11-04 12:15:01 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, filename, -1, file, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
|
2005-04-16 12:47:46 +02:00
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
|
|
|
case HH_DISPLAY_SEARCH:
|
|
|
|
case HH_HELP_CONTEXT:
|
2005-11-04 12:15:01 +01:00
|
|
|
FIXME("Not all HH cases handled correctly\n");
|
|
|
|
doWinMain(GetModuleHandleW(NULL), file);
|
2005-11-07 12:08:47 +01:00
|
|
|
break;
|
2006-01-10 20:23:56 +01:00
|
|
|
default:
|
|
|
|
FIXME("HH case %s not handled.\n", command_to_string( command ));
|
2005-04-16 12:47:46 +02:00
|
|
|
}
|
2007-02-22 22:49:13 +01:00
|
|
|
hhctrl_free(file);
|
2005-11-07 12:08:47 +01:00
|
|
|
return 0;
|
2004-04-22 05:45:00 +02:00
|
|
|
}
|
|
|
|
|
2004-06-01 21:44:59 +02:00
|
|
|
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
|
2004-04-22 05:45:00 +02:00
|
|
|
{
|
2004-06-01 21:44:59 +02:00
|
|
|
WCHAR *wfile = NULL;
|
|
|
|
HWND result;
|
|
|
|
|
2005-04-11 14:47:40 +02:00
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
|
2005-04-16 12:47:46 +02:00
|
|
|
|
2007-02-22 22:49:13 +01:00
|
|
|
wfile = hhctrl_alloc(len*sizeof(WCHAR));
|
2005-04-11 14:47:40 +02:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
|
|
|
|
}
|
2005-04-16 12:47:46 +02:00
|
|
|
|
2004-06-01 21:44:59 +02:00
|
|
|
result = HtmlHelpW( caller, wfile, command, data );
|
|
|
|
|
2007-02-22 22:49:13 +01:00
|
|
|
hhctrl_free(wfile);
|
2004-06-01 21:44:59 +02:00
|
|
|
return result;
|
2004-04-22 05:45:00 +02:00
|
|
|
}
|