hhctrl.ocx: Added HH_HELP_CONTEXT implementation.
This commit is contained in:
parent
5d011551a3
commit
736ef403a9
|
@ -146,6 +146,53 @@ static BOOL ReadChmSystem(CHMInfo *chm)
|
||||||
return SUCCEEDED(hres);
|
return SUCCEEDED(hres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
|
||||||
|
{
|
||||||
|
IStream *ivb_stream;
|
||||||
|
DWORD size, read, i;
|
||||||
|
DWORD *buf;
|
||||||
|
LPCSTR ret = NULL;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
static const WCHAR wszIVB[] = {'#','I','V','B',0};
|
||||||
|
|
||||||
|
hres = IStorage_OpenStream(chm->pStorage, wszIVB, NULL, STGM_READ, 0, &ivb_stream);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
WARN("Could not open #IVB stream: %08x\n", hres);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = IStream_Read(ivb_stream, &size, sizeof(size), &read);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
WARN("Read failed: %08x\n", hres);
|
||||||
|
IStream_Release(ivb_stream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = hhctrl_alloc(size);
|
||||||
|
hres = IStream_Read(ivb_stream, buf, size, &read);
|
||||||
|
IStream_Release(ivb_stream);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
WARN("Read failed: %08x\n", hres);
|
||||||
|
hhctrl_free(buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size /= 2*sizeof(DWORD);
|
||||||
|
|
||||||
|
for(i=0; i<size; i++) {
|
||||||
|
if(buf[2*i] == index) {
|
||||||
|
ret = GetChmString(chm, buf[2*i+1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hhctrl_free(buf);
|
||||||
|
|
||||||
|
TRACE("returning %s\n", debugstr_a(ret));
|
||||||
|
return strdupAtoW(ret);
|
||||||
|
}
|
||||||
|
|
||||||
/* Loads the HH_WINTYPE data from the CHM file
|
/* Loads the HH_WINTYPE data from the CHM file
|
||||||
*
|
*
|
||||||
* FIXME: There may be more than one window type in the file, so
|
* FIXME: There may be more than one window type in the file, so
|
||||||
|
|
|
@ -57,15 +57,32 @@ static LPWSTR HH_LoadString(DWORD dwID)
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
|
||||||
|
{
|
||||||
|
VARIANT url;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
V_VT(&url) = VT_BSTR;
|
||||||
|
V_BSTR(&url) = SysAllocString(surl);
|
||||||
|
|
||||||
|
hres = IWebBrowser2_Navigate2(info->web_browser, &url, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
VariantClear(&url);
|
||||||
|
|
||||||
|
return SUCCEEDED(hres);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
||||||
{
|
{
|
||||||
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
||||||
WCHAR full_path[MAX_PATH];
|
WCHAR full_path[MAX_PATH];
|
||||||
VARIANT url;
|
LPWSTR ptr;
|
||||||
|
|
||||||
static const WCHAR url_format[] =
|
static const WCHAR url_format[] =
|
||||||
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','/','%','s',0};
|
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','/','%','s',0};
|
||||||
|
|
||||||
|
TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
|
||||||
|
|
||||||
if (!info->web_browser)
|
if (!info->web_browser)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -76,13 +93,11 @@ BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
||||||
|
|
||||||
wsprintfW(buf, url_format, full_path, index);
|
wsprintfW(buf, url_format, full_path, index);
|
||||||
|
|
||||||
V_VT(&url) = VT_BSTR;
|
/* FIXME: HACK */
|
||||||
V_BSTR(&url) = SysAllocString(buf);
|
if((ptr = strchrW(buf, '#')))
|
||||||
|
*ptr = 0;
|
||||||
|
|
||||||
IWebBrowser2_Navigate2(info->web_browser, &url, 0, 0, 0, 0);
|
return NavigateToUrl(info, buf);
|
||||||
VariantClear(&url);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Size Bar */
|
/* Size Bar */
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* hhctrl implementation
|
* hhctrl implementation
|
||||||
*
|
*
|
||||||
* Copyright 2004 Krzysztof Foltman
|
* Copyright 2004 Krzysztof Foltman
|
||||||
|
* Copyright 2007 Jacek Caban for CodeWeavers
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
|
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
|
||||||
|
|
||||||
HINSTANCE hhctrl_hinstance;
|
HINSTANCE hhctrl_hinstance;
|
||||||
BOOL hh_process;
|
BOOL hh_process = FALSE;
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
{
|
{
|
||||||
|
@ -84,9 +85,11 @@ static const char *command_to_string(UINT command)
|
||||||
#undef X
|
#undef X
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* HtmlHelpW (hhctrl.ocx.15)
|
||||||
|
*/
|
||||||
HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
|
HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
|
||||||
{
|
{
|
||||||
|
|
||||||
TRACE("(%p, %s, command=%s, data=%d)\n",
|
TRACE("(%p, %s, command=%s, data=%d)\n",
|
||||||
caller, debugstr_w( filename ),
|
caller, debugstr_w( filename ),
|
||||||
command_to_string( command ), data);
|
command_to_string( command ), data);
|
||||||
|
@ -95,8 +98,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
|
||||||
{
|
{
|
||||||
case HH_DISPLAY_TOPIC:
|
case HH_DISPLAY_TOPIC:
|
||||||
case HH_DISPLAY_TOC:
|
case HH_DISPLAY_TOC:
|
||||||
case HH_DISPLAY_SEARCH:
|
case HH_DISPLAY_SEARCH:{
|
||||||
case HH_HELP_CONTEXT: {
|
|
||||||
HHInfo *info;
|
HHInfo *info;
|
||||||
BOOL res;
|
BOOL res;
|
||||||
|
|
||||||
|
@ -110,6 +112,23 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
|
||||||
|
|
||||||
return NULL; /* FIXME */
|
return NULL; /* FIXME */
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
hhctrl_free(url);
|
||||||
|
|
||||||
|
return NULL; /* FIXME */
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
FIXME("HH case %s not handled.\n", command_to_string( command ));
|
FIXME("HH case %s not handled.\n", command_to_string( command ));
|
||||||
}
|
}
|
||||||
|
@ -117,6 +136,9 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* HtmlHelpA (hhctrl.ocx.14)
|
||||||
|
*/
|
||||||
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
|
HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
|
||||||
{
|
{
|
||||||
WCHAR *wfile = NULL;
|
WCHAR *wfile = NULL;
|
||||||
|
|
|
@ -79,9 +79,11 @@ void DoPageAction(HHInfo*,DWORD);
|
||||||
CHMInfo *OpenCHM(LPCWSTR szFile);
|
CHMInfo *OpenCHM(LPCWSTR szFile);
|
||||||
BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
|
BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
|
||||||
CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
|
CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
|
||||||
|
LPWSTR FindContextAlias(CHMInfo*,DWORD);
|
||||||
|
|
||||||
HHInfo *CreateHelpViewer(LPCWSTR);
|
HHInfo *CreateHelpViewer(LPCWSTR);
|
||||||
void ReleaseHelpViewer(HHInfo*);
|
void ReleaseHelpViewer(HHInfo*);
|
||||||
|
BOOL NavigateToUrl(HHInfo*,LPCWSTR);
|
||||||
BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
|
BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
|
||||||
|
|
||||||
/* memory allocation functions */
|
/* memory allocation functions */
|
||||||
|
|
Loading…
Reference in New Issue