hhctrl.ocx: Use mk as default protocol and code clean up.

This commit is contained in:
Jacek Caban 2007-02-06 20:47:29 +01:00 committed by Alexandre Julliard
parent f9a7886121
commit 719bfaf4b0
5 changed files with 38 additions and 45 deletions

View File

@ -174,13 +174,3 @@ void CHM_CloseCHM(CHMInfo *pCHMInfo)
IITStorage_Release(pCHMInfo->pITStorage);
IStorage_Release(pCHMInfo->pStorage);
}
/* Creates a Url of a CHM file that can be used with WB_Navigate */
void CHM_CreateITSUrl(CHMInfo *pChmInfo, LPCWSTR szIndex, LPWSTR szUrl)
{
static const WCHAR formatW[] = {
'i','t','s',':','%','s',':',':','%','s',0
};
wsprintfW(szUrl, formatW, pChmInfo->szFile, szIndex);
}

View File

@ -33,6 +33,5 @@ typedef struct CHMInfo
BOOL CHM_OpenCHM(CHMInfo *pCHMInfo, LPCWSTR szFile);
BOOL CHM_LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
void CHM_CloseCHM(CHMInfo *pCHMInfo);
void CHM_CreateITSUrl(CHMInfo *pCHMInfo, LPCWSTR szIndex, LPWSTR szUrl);
#endif

View File

@ -20,6 +20,8 @@
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
@ -28,12 +30,18 @@
#include "commctrl.h"
#include "htmlhelp.h"
#include "ole2.h"
#include "exdisp.h"
#include "wininet.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "resource.h"
#include "chm.h"
#include "webbrowser.h"
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
static void Help_OnSize(HWND hWnd);
/* Window type defaults */
@ -87,6 +95,34 @@ static LPWSTR HH_LoadString(DWORD dwID)
return string;
}
static BOOL NavigateToChm(WBInfo *pWBInfo, LPCWSTR file, LPCWSTR index)
{
WCHAR buf[INTERNET_MAX_URL_LENGTH];
WCHAR full_path[MAX_PATH];
VARIANT url;
static const WCHAR url_format[] =
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','/','%','s',0};
if (!pWBInfo->pWebBrowser2)
return FALSE;
if(!GetFullPathNameW(file, sizeof(full_path), full_path, NULL)) {
WARN("GetFullPathName failed: %u\n", GetLastError());
return FALSE;
}
wsprintfW(buf, url_format, full_path, index);
V_VT(&url) = VT_BSTR;
V_BSTR(&url) = SysAllocString(buf);
IWebBrowser2_Navigate2(pWBInfo->pWebBrowser2, &url, 0, 0, 0, 0);
VariantClear(&url);
return TRUE;
}
/* Size Bar */
#define SIZEBAR_WIDTH 4
@ -321,13 +357,8 @@ static void TB_OnClick(HWND hWnd, DWORD dwID)
WB_DoPageAction(pHHInfo->pWBInfo, WB_GOBACK);
break;
case IDTB_HOME:
{
WCHAR szUrl[MAX_PATH];
CHM_CreateITSUrl(pHHInfo->pCHMInfo, pHHInfo->pHHWinType->pszHome, szUrl);
WB_Navigate(pHHInfo->pWBInfo, szUrl);
NavigateToChm(pHHInfo->pWBInfo, pHHInfo->pCHMInfo->szFile, pHHInfo->pHHWinType->pszHome);
break;
}
case IDTB_FORWARD:
WB_DoPageAction(pHHInfo->pWBInfo, WB_GOFORWARD);
break;
@ -821,15 +852,6 @@ static void HH_Close(HHInfo *pHHInfo)
}
}
static void HH_OpenDefaultTopic(HHInfo *pHHInfo)
{
WCHAR url[MAX_PATH];
LPCWSTR defTopic = pHHInfo->pHHWinType->pszFile;
CHM_CreateITSUrl(pHHInfo->pCHMInfo, defTopic, url);
WB_Navigate(pHHInfo->pWBInfo, url);
}
static BOOL HH_OpenCHM(HHInfo *pHHInfo)
{
if (!CHM_OpenCHM(pHHInfo->pCHMInfo, pHHInfo->szCmdLine))
@ -857,7 +879,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
return -1;
}
HH_OpenDefaultTopic(pHHInfo);
NavigateToChm(pHHInfo->pWBInfo, pHHInfo->pCHMInfo->szFile, pHHInfo->pHHWinType->pszFile);
while (GetMessageW(&msg, 0, 0, 0))
{

View File

@ -668,23 +668,6 @@ void WB_UnEmbedBrowser(WBInfo *pWBInfo)
}
}
BOOL WB_Navigate(WBInfo *pWBInfo, LPCWSTR szUrl)
{
IWebBrowser2 *pWebBrowser2 = pWBInfo->pWebBrowser2;
VARIANT myURL;
if (!pWebBrowser2)
return FALSE;
V_VT(&myURL) = VT_BSTR;
V_BSTR(&myURL) = SysAllocString(szUrl);
IWebBrowser2_Navigate2(pWebBrowser2, &myURL, 0, 0, 0, 0);
VariantClear(&myURL);
return TRUE;
}
void WB_ResizeBrowser(WBInfo *pWBInfo, DWORD dwWidth, DWORD dwHeight)
{
IWebBrowser2 *pWebBrowser2 = pWBInfo->pWebBrowser2;

View File

@ -42,7 +42,6 @@ typedef struct WBInfo
BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent);
void WB_UnEmbedBrowser(WBInfo *pWBInfo);
BOOL WB_Navigate(WBInfo *pWBInfo, LPCWSTR szUrl);
void WB_ResizeBrowser(WBInfo *pWBInfo, DWORD dwWidth, DWORD dwHeight);
void WB_DoPageAction(WBInfo *pWBInfo, DWORD dwAction);