2004-04-22 05:45:00 +02:00
|
|
|
/*
|
|
|
|
* hhctrl implementation
|
|
|
|
*
|
|
|
|
* Copyright 2004 Krzysztof Foltman
|
2007-02-28 03:55:39 +01:00
|
|
|
* Copyright 2007 Jacek Caban for CodeWeavers
|
2004-04-22 05:45:00 +02: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 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
|
|
|
|
2010-12-22 15:52:33 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "htmlhelp.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "rpcproxy.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);
|
|
|
|
|
2007-02-22 22:48:35 +01:00
|
|
|
HINSTANCE hhctrl_hinstance;
|
2007-02-28 03:55:39 +01:00
|
|
|
BOOL hh_process = FALSE;
|
2007-02-22 22:48:35 +01:00
|
|
|
|
2012-07-12 18:21:36 +02:00
|
|
|
|
2007-02-22 22:48:35 +01: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;
|
|
|
|
}
|
|
|
|
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 );
|
2007-05-02 18:15:58 +02:00
|
|
|
X( HH_SAFE_DISPLAY_TOPIC );
|
2005-04-16 12:47:46 +02:00
|
|
|
X( HH_PRETRANSLATEMESSAGE );
|
|
|
|
X( HH_SET_GLOBAL_PROPERTY );
|
|
|
|
default: return "???";
|
|
|
|
}
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2019-08-24 20:50:24 +02:00
|
|
|
static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
|
2009-07-01 11:54:44 +02:00
|
|
|
{
|
|
|
|
static const WCHAR helpW[] = {'\\','h','e','l','p','\\',0};
|
2011-06-29 17:51:05 +02:00
|
|
|
static const WCHAR delimW[] = {':',':',0};
|
|
|
|
static const WCHAR delim2W[] = {'>',0};
|
|
|
|
|
2019-08-24 20:50:24 +02:00
|
|
|
DWORD env_len;
|
2019-09-05 02:18:17 +02:00
|
|
|
WCHAR *filename, *extra;
|
2019-08-24 20:50:24 +02:00
|
|
|
|
|
|
|
env_filename = skip_schema(env_filename);
|
2011-06-29 17:51:05 +02:00
|
|
|
|
|
|
|
/* the format is "helpFile[::/index][>window]" */
|
|
|
|
if (index) *index = NULL;
|
|
|
|
if (window) *window = NULL;
|
|
|
|
|
2019-08-24 20:50:24 +02:00
|
|
|
env_len = ExpandEnvironmentStringsW(env_filename, NULL, 0);
|
|
|
|
if (!env_len)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
filename = heap_alloc(env_len * sizeof(WCHAR));
|
|
|
|
if (filename == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ExpandEnvironmentStringsW(env_filename, filename, env_len);
|
|
|
|
|
2019-06-05 08:35:40 +02:00
|
|
|
extra = wcsstr(filename, delim2W);
|
2011-06-29 17:51:05 +02:00
|
|
|
if (extra)
|
|
|
|
{
|
2019-09-05 02:18:17 +02:00
|
|
|
*extra = 0;
|
2011-06-29 17:51:05 +02:00
|
|
|
if (window)
|
|
|
|
*window = strdupW(extra+1);
|
|
|
|
}
|
|
|
|
|
2019-06-05 08:35:40 +02:00
|
|
|
extra = wcsstr(filename, delimW);
|
2011-06-29 17:51:05 +02:00
|
|
|
if (extra)
|
|
|
|
{
|
2019-09-05 02:18:17 +02:00
|
|
|
*extra = 0;
|
2011-06-29 17:51:05 +02:00
|
|
|
if (index)
|
|
|
|
*index = strdupW(extra+2);
|
|
|
|
}
|
2009-07-01 11:54:44 +02:00
|
|
|
|
|
|
|
GetFullPathNameW(filename, buflen, fullname, NULL);
|
|
|
|
if (GetFileAttributesW(fullname) == INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
GetWindowsDirectoryW(fullname, buflen);
|
2019-06-05 08:35:40 +02:00
|
|
|
lstrcatW(fullname, helpW);
|
|
|
|
lstrcatW(fullname, filename);
|
2009-07-01 11:54:44 +02:00
|
|
|
}
|
2019-08-24 20:50:24 +02:00
|
|
|
|
|
|
|
heap_free(filename);
|
|
|
|
|
2009-07-01 11:54:44 +02:00
|
|
|
return (GetFileAttributesW(fullname) != INVALID_FILE_ATTRIBUTES);
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:55:39 +01:00
|
|
|
/******************************************************************
|
2007-06-12 17:50:32 +02:00
|
|
|
* HtmlHelpW (HHCTRL.OCX.15)
|
2007-02-28 03:55:39 +01:00
|
|
|
*/
|
2007-05-02 18:15:58 +02:00
|
|
|
HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR data)
|
2004-04-22 05:45:00 +02:00
|
|
|
{
|
2009-07-01 11:54:44 +02:00
|
|
|
WCHAR fullname[MAX_PATH];
|
|
|
|
|
2007-05-02 18:15:58 +02:00
|
|
|
TRACE("(%p, %s, command=%s, data=%lx)\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
|
|
|
|
2007-02-28 03:53:37 +01:00
|
|
|
switch (command)
|
2005-11-04 12:15:01 +01:00
|
|
|
{
|
2007-02-28 03:53:37 +01:00
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
2011-09-28 04:01:38 +02:00
|
|
|
case HH_DISPLAY_INDEX:
|
2007-02-28 03:55:39 +01:00
|
|
|
case HH_DISPLAY_SEARCH:{
|
2007-02-28 03:53:37 +01:00
|
|
|
BOOL res;
|
2011-09-28 04:01:38 +02:00
|
|
|
NMHDR nmhdr;
|
2012-08-30 20:16:54 +02:00
|
|
|
HHInfo *info = NULL;
|
2012-07-12 18:21:36 +02:00
|
|
|
WCHAR *window = NULL;
|
2011-06-29 17:51:05 +02:00
|
|
|
const WCHAR *index = NULL;
|
2012-07-12 18:21:36 +02:00
|
|
|
WCHAR *default_index = NULL;
|
2011-09-28 04:01:38 +02:00
|
|
|
int tab_index = TAB_CONTENTS;
|
2005-11-04 12:15:01 +01:00
|
|
|
|
2008-05-20 07:40:27 +02:00
|
|
|
if (!filename)
|
|
|
|
return NULL;
|
|
|
|
|
2012-07-12 18:21:36 +02:00
|
|
|
if (!resolve_filename(filename, fullname, MAX_PATH, &default_index, &window))
|
2009-07-01 11:54:44 +02:00
|
|
|
{
|
|
|
|
WARN("can't find %s\n", debugstr_w(filename));
|
|
|
|
return 0;
|
|
|
|
}
|
2011-09-28 04:02:11 +02:00
|
|
|
index = default_index;
|
2009-07-01 11:54:44 +02:00
|
|
|
|
2012-08-30 20:16:54 +02:00
|
|
|
if (window)
|
|
|
|
info = find_window(window);
|
|
|
|
|
|
|
|
info = CreateHelpViewer(info, fullname, caller);
|
2008-04-28 22:41:47 +02:00
|
|
|
if(!info)
|
2012-07-12 18:21:36 +02:00
|
|
|
{
|
|
|
|
heap_free(default_index);
|
|
|
|
heap_free(window);
|
2008-04-28 22:41:47 +02:00
|
|
|
return NULL;
|
2012-07-12 18:21:36 +02:00
|
|
|
}
|
2008-04-28 22:41:47 +02:00
|
|
|
|
|
|
|
if(!index)
|
|
|
|
index = info->WinType.pszFile;
|
2012-08-30 03:45:27 +02:00
|
|
|
if(!info->WinType.pszType)
|
|
|
|
info->WinType.pszType = info->stringsW.pszType = window;
|
2012-07-12 18:21:36 +02:00
|
|
|
else
|
|
|
|
heap_free(window);
|
2007-02-28 03:53:37 +01:00
|
|
|
|
2011-09-28 04:02:11 +02:00
|
|
|
/* called to load a specified topic */
|
|
|
|
switch(command)
|
|
|
|
{
|
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
|
|
|
if (data)
|
2014-02-26 03:10:58 +01:00
|
|
|
{
|
|
|
|
static const WCHAR delimW[] = {':',':',0};
|
|
|
|
const WCHAR *i = (const WCHAR *)data;
|
|
|
|
|
2019-06-05 08:35:40 +02:00
|
|
|
index = wcsstr(i, delimW);
|
2014-02-26 03:10:58 +01:00
|
|
|
if(index)
|
|
|
|
{
|
|
|
|
if(memcmp(info->pCHMInfo->szFile, i, index-i))
|
|
|
|
FIXME("Opening a CHM file in the context of another is not supported.\n");
|
2019-06-05 08:35:40 +02:00
|
|
|
index += lstrlenW(delimW);
|
2014-02-26 03:10:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
index = i;
|
|
|
|
}
|
2011-09-28 04:02:11 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-28 22:41:47 +02:00
|
|
|
res = NavigateToChm(info, info->pCHMInfo->szFile, index);
|
2012-07-12 18:21:36 +02:00
|
|
|
heap_free(default_index);
|
2011-06-29 17:51:05 +02:00
|
|
|
|
2008-04-28 22:41:47 +02:00
|
|
|
if(!res)
|
2007-05-02 18:16:32 +02:00
|
|
|
{
|
2008-04-28 22:41:47 +02:00
|
|
|
ReleaseHelpViewer(info);
|
|
|
|
return NULL;
|
2007-05-02 18:16:32 +02:00
|
|
|
}
|
2011-09-28 04:01:38 +02:00
|
|
|
|
|
|
|
switch(command)
|
|
|
|
{
|
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
|
|
|
tab_index = TAB_CONTENTS;
|
|
|
|
break;
|
|
|
|
case HH_DISPLAY_INDEX:
|
|
|
|
tab_index = TAB_INDEX;
|
|
|
|
if (data)
|
|
|
|
FIXME("Should select keyword '%s'.\n", debugstr_w((WCHAR *)data));
|
|
|
|
break;
|
|
|
|
case HH_DISPLAY_SEARCH:
|
|
|
|
tab_index = TAB_SEARCH;
|
|
|
|
if (data)
|
|
|
|
FIXME("Should display search specified by HH_FTS_QUERY structure.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* open the requested tab */
|
|
|
|
memset(&nmhdr, 0, sizeof(nmhdr));
|
|
|
|
nmhdr.code = TCN_SELCHANGE;
|
|
|
|
SendMessageW(info->hwndTabCtrl, TCM_SETCURSEL, (WPARAM)info->tabs[tab_index].id, 0);
|
|
|
|
SendMessageW(info->WinType.hwndNavigation, WM_NOTIFY, 0, (LPARAM)&nmhdr);
|
|
|
|
|
2008-04-16 03:03:49 +02:00
|
|
|
return info->WinType.hwndHelp;
|
2005-04-16 12:47:46 +02:00
|
|
|
}
|
2007-02-28 03:55:39 +01:00
|
|
|
case HH_HELP_CONTEXT: {
|
2012-10-03 17:22:11 +02:00
|
|
|
WCHAR *window = NULL;
|
|
|
|
HHInfo *info = NULL;
|
2007-02-28 03:55:39 +01:00
|
|
|
LPWSTR url;
|
|
|
|
|
2008-05-20 07:40:27 +02:00
|
|
|
if (!filename)
|
|
|
|
return NULL;
|
|
|
|
|
2012-10-03 17:22:11 +02:00
|
|
|
if (!resolve_filename(filename, fullname, MAX_PATH, NULL, &window))
|
2009-07-01 11:54:44 +02:00
|
|
|
{
|
|
|
|
WARN("can't find %s\n", debugstr_w(filename));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-03 17:22:11 +02:00
|
|
|
if (window)
|
|
|
|
info = find_window(window);
|
|
|
|
|
|
|
|
info = CreateHelpViewer(info, fullname, caller);
|
2007-02-28 03:55:39 +01:00
|
|
|
if(!info)
|
2012-10-03 17:22:11 +02:00
|
|
|
{
|
|
|
|
heap_free(window);
|
2007-02-28 03:55:39 +01:00
|
|
|
return NULL;
|
2012-10-03 17:22:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!info->WinType.pszType)
|
|
|
|
info->WinType.pszType = info->stringsW.pszType = window;
|
|
|
|
else
|
|
|
|
heap_free(window);
|
2007-02-28 03:55:39 +01:00
|
|
|
|
|
|
|
url = FindContextAlias(info->pCHMInfo, data);
|
|
|
|
if(!url)
|
2008-04-28 22:42:56 +02:00
|
|
|
{
|
2013-11-06 19:59:16 +01:00
|
|
|
if(!data) /* there may legitimately be no context alias for id 0 */
|
|
|
|
return info->WinType.hwndHelp;
|
2008-04-28 22:42:56 +02:00
|
|
|
ReleaseHelpViewer(info);
|
2007-02-28 03:55:39 +01:00
|
|
|
return NULL;
|
2008-04-28 22:42:56 +02:00
|
|
|
}
|
2007-02-28 03:55:39 +01:00
|
|
|
|
|
|
|
NavigateToUrl(info, url);
|
2007-12-09 16:29:44 +01:00
|
|
|
heap_free(url);
|
2008-04-16 03:03:49 +02:00
|
|
|
return info->WinType.hwndHelp;
|
2007-02-28 03:55:39 +01:00
|
|
|
}
|
2007-10-15 20:19:56 +02:00
|
|
|
case HH_PRETRANSLATEMESSAGE: {
|
|
|
|
static BOOL warned = FALSE;
|
|
|
|
|
|
|
|
if (!warned)
|
|
|
|
{
|
|
|
|
FIXME("HH_PRETRANSLATEMESSAGE unimplemented\n");
|
|
|
|
warned = TRUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-12 18:21:36 +02:00
|
|
|
case HH_CLOSE_ALL: {
|
|
|
|
HHInfo *info, *next;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(info, next, &window_list, HHInfo, entry)
|
|
|
|
{
|
|
|
|
TRACE("Destroying window %s.\n", debugstr_w(info->WinType.pszType));
|
|
|
|
ReleaseHelpViewer(info);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-08-30 20:16:54 +02:00
|
|
|
case HH_SET_WIN_TYPE: {
|
|
|
|
HH_WINTYPEW *wintype = (HH_WINTYPEW *)data;
|
|
|
|
WCHAR *window = NULL;
|
|
|
|
HHInfo *info = NULL;
|
|
|
|
|
|
|
|
if (!filename && wintype->pszType)
|
|
|
|
window = strdupW(wintype->pszType);
|
|
|
|
else if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
|
|
|
|
{
|
|
|
|
WARN("can't find window name: %s\n", debugstr_w(filename));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
info = find_window(window);
|
|
|
|
if (!info)
|
|
|
|
{
|
|
|
|
info = heap_alloc_zero(sizeof(HHInfo));
|
|
|
|
info->WinType.pszType = info->stringsW.pszType = window;
|
|
|
|
list_add_tail(&window_list, &info->entry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
heap_free(window);
|
|
|
|
|
|
|
|
TRACE("Changing WINTYPE, fsValidMembers=0x%x\n", wintype->fsValidMembers);
|
|
|
|
|
2012-09-05 18:24:28 +02:00
|
|
|
MergeChmProperties(wintype, info, TRUE);
|
|
|
|
UpdateHelpWindow(info);
|
2012-08-30 20:16:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2012-08-31 23:26:12 +02:00
|
|
|
case HH_GET_WIN_TYPE: {
|
|
|
|
HH_WINTYPEW *wintype = (HH_WINTYPEW *)data;
|
|
|
|
WCHAR *window = NULL;
|
|
|
|
HHInfo *info = NULL;
|
|
|
|
|
|
|
|
if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
|
|
|
|
{
|
|
|
|
WARN("can't find window name: %s\n", debugstr_w(filename));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
info = find_window(window);
|
|
|
|
if (!info)
|
|
|
|
{
|
|
|
|
WARN("Could not find window named %s.\n", debugstr_w(window));
|
|
|
|
heap_free(window);
|
|
|
|
return (HWND)~0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Retrieving WINTYPE for %s.\n", debugstr_w(window));
|
|
|
|
*wintype = info->WinType;
|
|
|
|
heap_free(window);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-28 03:53:37 +01:00
|
|
|
default:
|
|
|
|
FIXME("HH case %s not handled.\n", command_to_string( command ));
|
|
|
|
}
|
|
|
|
|
2005-11-07 12:08:47 +01:00
|
|
|
return 0;
|
2004-04-22 05:45:00 +02:00
|
|
|
}
|
|
|
|
|
2012-08-31 23:26:12 +02:00
|
|
|
static void wintypeAtoW(const HH_WINTYPEA *data, HH_WINTYPEW *wdata, struct wintype_stringsW *stringsW)
|
2012-08-30 20:16:54 +02:00
|
|
|
{
|
|
|
|
memcpy(wdata, data, sizeof(*data));
|
|
|
|
/* convert all of the ANSI strings to Unicode */
|
|
|
|
wdata->pszType = stringsW->pszType = strdupAtoW(data->pszType);
|
|
|
|
wdata->pszCaption = stringsW->pszCaption = strdupAtoW(data->pszCaption);
|
|
|
|
wdata->pszToc = stringsW->pszToc = strdupAtoW(data->pszToc);
|
|
|
|
wdata->pszIndex = stringsW->pszIndex = strdupAtoW(data->pszIndex);
|
|
|
|
wdata->pszFile = stringsW->pszFile = strdupAtoW(data->pszFile);
|
|
|
|
wdata->pszHome = stringsW->pszHome = strdupAtoW(data->pszHome);
|
|
|
|
wdata->pszJump1 = stringsW->pszJump1 = strdupAtoW(data->pszJump1);
|
|
|
|
wdata->pszJump2 = stringsW->pszJump2 = strdupAtoW(data->pszJump2);
|
|
|
|
wdata->pszUrlJump1 = stringsW->pszUrlJump1 = strdupAtoW(data->pszUrlJump1);
|
|
|
|
wdata->pszUrlJump2 = stringsW->pszUrlJump2 = strdupAtoW(data->pszUrlJump2);
|
|
|
|
wdata->pszCustomTabs = stringsW->pszCustomTabs = strdupAtoW(data->pszCustomTabs);
|
2012-08-31 23:26:12 +02:00
|
|
|
}
|
2012-08-30 20:16:54 +02:00
|
|
|
|
2012-08-31 23:26:12 +02:00
|
|
|
static void wintypeWtoA(const HH_WINTYPEW *wdata, HH_WINTYPEA *data, struct wintype_stringsA *stringsA)
|
|
|
|
{
|
|
|
|
memcpy(data, wdata, sizeof(*wdata));
|
|
|
|
/* convert all of the Unicode strings to ANSI */
|
|
|
|
data->pszType = stringsA->pszType = strdupWtoA(wdata->pszType);
|
|
|
|
data->pszCaption = stringsA->pszCaption = strdupWtoA(wdata->pszCaption);
|
|
|
|
data->pszToc = stringsA->pszToc = strdupWtoA(wdata->pszToc);
|
|
|
|
data->pszIndex = stringsA->pszFile = strdupWtoA(wdata->pszIndex);
|
|
|
|
data->pszFile = stringsA->pszFile = strdupWtoA(wdata->pszFile);
|
|
|
|
data->pszHome = stringsA->pszHome = strdupWtoA(wdata->pszHome);
|
|
|
|
data->pszJump1 = stringsA->pszJump1 = strdupWtoA(wdata->pszJump1);
|
|
|
|
data->pszJump2 = stringsA->pszJump2 = strdupWtoA(wdata->pszJump2);
|
|
|
|
data->pszUrlJump1 = stringsA->pszUrlJump1 = strdupWtoA(wdata->pszUrlJump1);
|
|
|
|
data->pszUrlJump2 = stringsA->pszUrlJump2 = strdupWtoA(wdata->pszUrlJump2);
|
|
|
|
data->pszCustomTabs = stringsA->pszCustomTabs = strdupWtoA(wdata->pszCustomTabs);
|
2012-08-30 20:16:54 +02:00
|
|
|
}
|
|
|
|
|
2007-02-28 03:55:39 +01:00
|
|
|
/******************************************************************
|
2007-06-12 17:50:32 +02:00
|
|
|
* HtmlHelpA (HHCTRL.OCX.14)
|
2007-02-28 03:55:39 +01:00
|
|
|
*/
|
2007-05-02 18:15:58 +02:00
|
|
|
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data)
|
2004-04-22 05:45:00 +02:00
|
|
|
{
|
2012-08-30 20:16:54 +02:00
|
|
|
WCHAR *wfile = strdupAtoW( filename );
|
|
|
|
HWND result = 0;
|
2005-04-16 12:47:46 +02:00
|
|
|
|
2007-05-02 18:15:58 +02: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_KEYWORD_LOOKUP:
|
|
|
|
case HH_SYNC:
|
|
|
|
FIXME("structures not handled yet\n");
|
|
|
|
break;
|
|
|
|
|
2012-08-30 20:16:54 +02:00
|
|
|
case HH_SET_WIN_TYPE:
|
|
|
|
{
|
|
|
|
struct wintype_stringsW stringsW;
|
2012-08-31 23:26:12 +02:00
|
|
|
HH_WINTYPEW wdata;
|
|
|
|
|
|
|
|
wintypeAtoW((HH_WINTYPEA *)data, &wdata, &stringsW);
|
|
|
|
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
|
2012-08-30 20:16:54 +02:00
|
|
|
wintype_stringsW_free(&stringsW);
|
2012-08-31 23:26:12 +02:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
case HH_GET_WIN_TYPE:
|
|
|
|
{
|
|
|
|
HH_WINTYPEW wdata;
|
|
|
|
HHInfo *info;
|
|
|
|
|
|
|
|
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
|
|
|
|
if (!wdata.pszType) break;
|
|
|
|
info = find_window(wdata.pszType);
|
|
|
|
if (!info) break;
|
|
|
|
wintype_stringsA_free(&info->stringsA);
|
|
|
|
wintypeWtoA(&wdata, (HH_WINTYPEA *)data, &info->stringsA);
|
2012-08-30 20:16:54 +02:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-02 18:15:58 +02:00
|
|
|
case HH_DISPLAY_INDEX:
|
|
|
|
case HH_DISPLAY_TOPIC:
|
|
|
|
case HH_DISPLAY_TOC:
|
|
|
|
case HH_GET_WIN_HANDLE:
|
|
|
|
case HH_SAFE_DISPLAY_TOPIC:
|
2012-08-30 20:16:54 +02:00
|
|
|
{
|
|
|
|
WCHAR *wdata = strdupAtoW( (const char *)data );
|
|
|
|
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)wdata );
|
|
|
|
heap_free(wdata);
|
|
|
|
goto done;
|
|
|
|
}
|
2007-05-02 18:15:58 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-30 20:16:54 +02:00
|
|
|
result = HtmlHelpW( caller, wfile, command, data );
|
|
|
|
done:
|
2007-12-09 16:29:44 +01:00
|
|
|
heap_free(wfile);
|
2004-06-01 21:44:59 +02:00
|
|
|
return result;
|
2004-04-22 05:45:00 +02:00
|
|
|
}
|
2007-02-28 03:49:20 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
2007-06-12 17:50:32 +02:00
|
|
|
* doWinMain (HHCTRL.OCX.13)
|
2007-02-28 03:49:20 +01:00
|
|
|
*/
|
|
|
|
int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
|
|
|
|
{
|
|
|
|
MSG msg;
|
2010-01-29 00:16:54 +01:00
|
|
|
int len, buflen, mapid = -1;
|
2009-02-16 18:35:56 +01:00
|
|
|
WCHAR *filename;
|
|
|
|
char *endq = NULL;
|
2011-09-28 04:02:32 +02:00
|
|
|
HWND hwnd;
|
2007-02-28 03:49:20 +01:00
|
|
|
|
2007-02-28 03:54:25 +01:00
|
|
|
hh_process = TRUE;
|
|
|
|
|
2010-01-29 00:16:54 +01:00
|
|
|
/* Parse command line option of the HTML Help command.
|
|
|
|
*
|
|
|
|
* Note: The only currently handled action is "mapid",
|
|
|
|
* which corresponds to opening a specific page.
|
|
|
|
*/
|
|
|
|
while(*szCmdLine == '-')
|
|
|
|
{
|
|
|
|
LPSTR space, ptr;
|
|
|
|
|
|
|
|
ptr = szCmdLine + 1;
|
|
|
|
space = strchr(ptr, ' ');
|
|
|
|
if(!strncmp(ptr, "mapid", space-ptr))
|
|
|
|
{
|
|
|
|
char idtxt[10];
|
|
|
|
|
|
|
|
ptr += strlen("mapid")+1;
|
|
|
|
space = strchr(ptr, ' ');
|
2010-09-08 16:23:47 +02:00
|
|
|
/* command line ends without number */
|
|
|
|
if (!space)
|
|
|
|
return 0;
|
2010-01-29 00:16:54 +01:00
|
|
|
memcpy(idtxt, ptr, space-ptr);
|
|
|
|
idtxt[space-ptr] = '\0';
|
|
|
|
mapid = atoi(idtxt);
|
|
|
|
szCmdLine = space+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-09 16:14:28 +02:00
|
|
|
FIXME("Unhandled HTML Help command line parameter! (%.*s)\n", (int)(space-szCmdLine), szCmdLine);
|
2010-01-29 00:16:54 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:49:20 +01:00
|
|
|
/* FIXME: Check szCmdLine for bad arguments */
|
2009-02-16 18:35:56 +01:00
|
|
|
if (*szCmdLine == '\"')
|
|
|
|
endq = strchr(++szCmdLine, '\"');
|
|
|
|
|
|
|
|
if (endq)
|
|
|
|
len = endq - szCmdLine;
|
|
|
|
else
|
|
|
|
len = strlen(szCmdLine);
|
2010-09-08 16:23:47 +02:00
|
|
|
|
|
|
|
/* no filename given */
|
|
|
|
if (!len)
|
|
|
|
return 0;
|
|
|
|
|
2009-02-16 18:35:56 +01:00
|
|
|
buflen = MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, NULL, 0) + 1;
|
|
|
|
filename = heap_alloc(buflen * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, filename, buflen);
|
|
|
|
filename[buflen-1] = 0;
|
|
|
|
|
2010-01-29 00:16:54 +01:00
|
|
|
/* Open a specific help topic */
|
|
|
|
if(mapid != -1)
|
2011-09-28 04:02:32 +02:00
|
|
|
hwnd = HtmlHelpW(GetDesktopWindow(), filename, HH_HELP_CONTEXT, mapid);
|
2010-01-29 00:16:54 +01:00
|
|
|
else
|
2011-09-28 04:02:32 +02:00
|
|
|
hwnd = HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0);
|
2009-02-16 18:35:56 +01:00
|
|
|
|
|
|
|
heap_free(filename);
|
2007-02-28 03:49:20 +01:00
|
|
|
|
2011-09-28 04:02:32 +02:00
|
|
|
if (!hwnd)
|
|
|
|
{
|
|
|
|
ERR("Failed to open HTML Help file '%s'.\n", szCmdLine);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-28 03:49:20 +01:00
|
|
|
while (GetMessageW(&msg, 0, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-28 03:51:04 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
2007-06-12 17:50:32 +02:00
|
|
|
* DllGetClassObject (HHCTRL.OCX.@)
|
2007-02-28 03:51:04 +01: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;
|
|
|
|
}
|
2010-12-22 15:52:33 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (HHCTRL.OCX.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_register_resources( hhctrl_hinstance );
|
2010-12-22 15:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (HHCTRL.OCX.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_unregister_resources( hhctrl_hinstance );
|
2010-12-22 15:52:33 +01:00
|
|
|
}
|