hhctrl.ocx: Merge WBInfo to HHInfo.
This commit is contained in:
parent
5a01e1020d
commit
24c13b9f8d
|
@ -43,16 +43,6 @@ static void Help_OnSize(HWND hWnd);
|
|||
|
||||
static const WCHAR szEmpty[] = {0};
|
||||
|
||||
typedef struct tagHHInfo
|
||||
{
|
||||
HH_WINTYPEW WinType;
|
||||
CHMInfo *pCHMInfo;
|
||||
WBInfo *pWBInfo;
|
||||
HWND hwndTabCtrl;
|
||||
HWND hwndSizeBar;
|
||||
HFONT hFont;
|
||||
} HHInfo;
|
||||
|
||||
/* Loads a string from the resource file */
|
||||
static LPWSTR HH_LoadString(DWORD dwID)
|
||||
{
|
||||
|
@ -68,7 +58,7 @@ static LPWSTR HH_LoadString(DWORD dwID)
|
|||
return string;
|
||||
}
|
||||
|
||||
static BOOL NavigateToChm(WBInfo *pWBInfo, LPCWSTR file, LPCWSTR index)
|
||||
static BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
||||
{
|
||||
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
||||
WCHAR full_path[MAX_PATH];
|
||||
|
@ -77,7 +67,7 @@ static BOOL NavigateToChm(WBInfo *pWBInfo, LPCWSTR file, LPCWSTR index)
|
|||
static const WCHAR url_format[] =
|
||||
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','/','%','s',0};
|
||||
|
||||
if (!pWBInfo->pWebBrowser2)
|
||||
if (!info->web_browser)
|
||||
return FALSE;
|
||||
|
||||
if(!GetFullPathNameW(file, sizeof(full_path), full_path, NULL)) {
|
||||
|
@ -90,7 +80,7 @@ static BOOL NavigateToChm(WBInfo *pWBInfo, LPCWSTR file, LPCWSTR index)
|
|||
V_VT(&url) = VT_BSTR;
|
||||
V_BSTR(&url) = SysAllocString(buf);
|
||||
|
||||
IWebBrowser2_Navigate2(pWBInfo->pWebBrowser2, &url, 0, 0, 0, 0);
|
||||
IWebBrowser2_Navigate2(info->web_browser, &url, 0, 0, 0, 0);
|
||||
VariantClear(&url);
|
||||
|
||||
return TRUE;
|
||||
|
@ -316,24 +306,24 @@ static void HH_RegisterChildWndClass(HHInfo *pHHInfo)
|
|||
|
||||
static void TB_OnClick(HWND hWnd, DWORD dwID)
|
||||
{
|
||||
HHInfo *pHHInfo = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
||||
HHInfo *info = (HHInfo *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
||||
|
||||
switch (dwID)
|
||||
{
|
||||
case IDTB_STOP:
|
||||
WB_DoPageAction(pHHInfo->pWBInfo, WB_STOP);
|
||||
DoPageAction(info, WB_STOP);
|
||||
break;
|
||||
case IDTB_REFRESH:
|
||||
WB_DoPageAction(pHHInfo->pWBInfo, WB_REFRESH);
|
||||
DoPageAction(info, WB_REFRESH);
|
||||
break;
|
||||
case IDTB_BACK:
|
||||
WB_DoPageAction(pHHInfo->pWBInfo, WB_GOBACK);
|
||||
DoPageAction(info, WB_GOBACK);
|
||||
break;
|
||||
case IDTB_HOME:
|
||||
NavigateToChm(pHHInfo->pWBInfo, pHHInfo->pCHMInfo->szFile, pHHInfo->WinType.pszHome);
|
||||
NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszHome);
|
||||
break;
|
||||
case IDTB_FORWARD:
|
||||
WB_DoPageAction(pHHInfo->pWBInfo, WB_GOFORWARD);
|
||||
DoPageAction(info, WB_GOFORWARD);
|
||||
break;
|
||||
case IDTB_EXPAND:
|
||||
case IDTB_CONTRACT:
|
||||
|
@ -580,7 +570,7 @@ static BOOL HH_AddHTMLPane(HHInfo *pHHInfo)
|
|||
if (!hWnd)
|
||||
return FALSE;
|
||||
|
||||
if (!WB_EmbedBrowser(pHHInfo->pWBInfo, hWnd))
|
||||
if (!InitWebBrowser(pHHInfo, hWnd))
|
||||
return FALSE;
|
||||
|
||||
/* store the pointer to the HH info struct */
|
||||
|
@ -623,7 +613,7 @@ static void Help_OnSize(HWND hWnd)
|
|||
|
||||
/* Resize browser window taking the frame size into account */
|
||||
dwSize = GetSystemMetrics(SM_CXFRAME);
|
||||
WB_ResizeBrowser(pHHInfo->pWBInfo, rc.right - dwSize, rc.bottom - dwSize);
|
||||
ResizeWebBrowser(pHHInfo, rc.right - dwSize, rc.bottom - dwSize);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK Help_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -795,11 +785,7 @@ static void HH_Close(HHInfo *info)
|
|||
if (info->pCHMInfo)
|
||||
CloseCHM(info->pCHMInfo);
|
||||
|
||||
if (info->pWBInfo)
|
||||
{
|
||||
WB_UnEmbedBrowser(info->pWBInfo);
|
||||
hhctrl_free(info->pWBInfo);
|
||||
}
|
||||
ReleaseWebBrowser(info);
|
||||
}
|
||||
|
||||
static HHInfo *HH_OpenHH(LPWSTR filename)
|
||||
|
@ -812,8 +798,6 @@ static HHInfo *HH_OpenHH(LPWSTR filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pHHInfo->pWBInfo = hhctrl_alloc(sizeof(WBInfo));
|
||||
|
||||
if (!CHM_LoadWinTypeFromCHM(pHHInfo->pCHMInfo, &pHHInfo->WinType)) {
|
||||
HH_Close(pHHInfo);
|
||||
return NULL;
|
||||
|
@ -838,7 +822,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
|
|||
return -1;
|
||||
}
|
||||
|
||||
NavigateToChm(pHHInfo->pWBInfo, pHHInfo->pCHMInfo->szFile, pHHInfo->WinType.pszFile);
|
||||
NavigateToChm(pHHInfo, pHHInfo->pCHMInfo->szFile, pHHInfo->WinType.pszFile);
|
||||
|
||||
while (GetMessageW(&msg, 0, 0, 0))
|
||||
{
|
||||
|
|
|
@ -57,18 +57,22 @@ typedef struct CHMInfo
|
|||
} CHMInfo;
|
||||
|
||||
|
||||
typedef struct WBInfo
|
||||
{
|
||||
IOleClientSite *pOleClientSite;
|
||||
IWebBrowser2 *pWebBrowser2;
|
||||
IOleObject *pBrowserObject;
|
||||
HWND hwndParent;
|
||||
} WBInfo;
|
||||
typedef struct {
|
||||
IOleClientSite *client_site;
|
||||
IWebBrowser2 *web_browser;
|
||||
IOleObject *wb_object;
|
||||
|
||||
BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent);
|
||||
void WB_UnEmbedBrowser(WBInfo *pWBInfo);
|
||||
void WB_ResizeBrowser(WBInfo *pWBInfo, DWORD dwWidth, DWORD dwHeight);
|
||||
void WB_DoPageAction(WBInfo *pWBInfo, DWORD dwAction);
|
||||
HH_WINTYPEW WinType;
|
||||
CHMInfo *pCHMInfo;
|
||||
HWND hwndTabCtrl;
|
||||
HWND hwndSizeBar;
|
||||
HFONT hFont;
|
||||
} HHInfo;
|
||||
|
||||
BOOL InitWebBrowser(HHInfo*,HWND);
|
||||
void ReleaseWebBrowser(HHInfo*);
|
||||
void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
|
||||
void DoPageAction(HHInfo*,DWORD);
|
||||
|
||||
CHMInfo *OpenCHM(LPCWSTR szFile);
|
||||
BOOL CHM_LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
|
||||
|
|
|
@ -567,7 +567,7 @@ static const IStorageVtbl MyIStorageTable =
|
|||
|
||||
static IStorage MyIStorage = { &MyIStorageTable };
|
||||
|
||||
BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent)
|
||||
BOOL InitWebBrowser(HHInfo *info, HWND hwndParent)
|
||||
{
|
||||
IOleClientSiteImpl *iOleClientSiteImpl;
|
||||
IOleInPlaceObject *inplace;
|
||||
|
@ -576,9 +576,6 @@ BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent)
|
|||
HRESULT hr;
|
||||
RECT rc;
|
||||
|
||||
/* clear out struct to keep from accessing invalid ptrs */
|
||||
ZeroMemory(pWBInfo, sizeof(WBInfo));
|
||||
|
||||
iOleClientSiteImpl = hhctrl_alloc_zero(sizeof(IOleClientSiteImpl));
|
||||
if (!iOleClientSiteImpl)
|
||||
return FALSE;
|
||||
|
@ -594,8 +591,8 @@ BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent)
|
|||
(IOleClientSite *)iOleClientSiteImpl, &MyIStorage,
|
||||
(void **)&browserObject);
|
||||
|
||||
pWBInfo->pOleClientSite = (IOleClientSite *)iOleClientSiteImpl;
|
||||
pWBInfo->pBrowserObject = browserObject;
|
||||
info->client_site = (IOleClientSite *)iOleClientSiteImpl;
|
||||
info->wb_object = browserObject;
|
||||
|
||||
if (FAILED(hr)) goto error;
|
||||
|
||||
|
@ -622,55 +619,51 @@ BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent)
|
|||
(void **)&webBrowser2);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pWBInfo->pWebBrowser2 = webBrowser2;
|
||||
pWBInfo->hwndParent = hwndParent;
|
||||
|
||||
info->web_browser = webBrowser2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
error:
|
||||
WB_UnEmbedBrowser(pWBInfo);
|
||||
ReleaseWebBrowser(info);
|
||||
hhctrl_free(iOleClientSiteImpl);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void WB_UnEmbedBrowser(WBInfo *pWBInfo)
|
||||
void ReleaseWebBrowser(HHInfo *info)
|
||||
{
|
||||
if (pWBInfo->pBrowserObject)
|
||||
if (info->wb_object)
|
||||
{
|
||||
IOleObject_Close(pWBInfo->pBrowserObject, OLECLOSE_NOSAVE);
|
||||
IOleObject_Release(pWBInfo->pBrowserObject);
|
||||
pWBInfo->pBrowserObject = NULL;
|
||||
IOleObject_Close(info->wb_object, OLECLOSE_NOSAVE);
|
||||
IOleObject_Release(info->wb_object);
|
||||
info->wb_object = NULL;
|
||||
}
|
||||
|
||||
if (pWBInfo->pWebBrowser2)
|
||||
if (info->web_browser)
|
||||
{
|
||||
IWebBrowser2_Release(pWBInfo->pWebBrowser2);
|
||||
pWBInfo->pWebBrowser2 = NULL;
|
||||
IWebBrowser2_Release(info->web_browser);
|
||||
info->web_browser = NULL;
|
||||
}
|
||||
|
||||
if (pWBInfo->pOleClientSite)
|
||||
if (info->client_site)
|
||||
{
|
||||
IOleClientSite_Release(pWBInfo->pOleClientSite);
|
||||
pWBInfo->pOleClientSite = NULL;
|
||||
IOleClientSite_Release(info->client_site);
|
||||
info->client_site = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void WB_ResizeBrowser(WBInfo *pWBInfo, DWORD dwWidth, DWORD dwHeight)
|
||||
void ResizeWebBrowser(HHInfo *info, DWORD dwWidth, DWORD dwHeight)
|
||||
{
|
||||
IWebBrowser2 *pWebBrowser2 = pWBInfo->pWebBrowser2;
|
||||
|
||||
if (!pWebBrowser2)
|
||||
if (!info->web_browser)
|
||||
return;
|
||||
|
||||
IWebBrowser2_put_Width(pWebBrowser2, dwWidth);
|
||||
IWebBrowser2_put_Height(pWebBrowser2, dwHeight);
|
||||
IWebBrowser2_put_Width(info->web_browser, dwWidth);
|
||||
IWebBrowser2_put_Height(info->web_browser, dwHeight);
|
||||
}
|
||||
|
||||
void WB_DoPageAction(WBInfo *pWBInfo, DWORD dwAction)
|
||||
void DoPageAction(HHInfo *info, DWORD dwAction)
|
||||
{
|
||||
IWebBrowser2 *pWebBrowser2 = pWBInfo->pWebBrowser2;
|
||||
IWebBrowser2 *pWebBrowser2 = info->web_browser;
|
||||
|
||||
if (!pWebBrowser2)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue