hhctrl.ocx: Move more code from doWinMain.
This commit is contained in:
parent
bf34ca2d03
commit
1a2456cc4c
|
@ -151,7 +151,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
|
||||||
* 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
|
||||||
* add the ability to choose a certain window type
|
* add the ability to choose a certain window type
|
||||||
*/
|
*/
|
||||||
BOOL CHM_LoadWinTypeFromCHM(CHMInfo *pChmInfo, HH_WINTYPEW *pHHWinType)
|
BOOL LoadWinTypeFromCHM(CHMInfo *pChmInfo, HH_WINTYPEW *pHHWinType)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER liOffset;
|
LARGE_INTEGER liOffset;
|
||||||
IStorage *pStorage = pChmInfo->pStorage;
|
IStorage *pStorage = pChmInfo->pStorage;
|
||||||
|
@ -209,7 +209,7 @@ CHMInfo *OpenCHM(LPCWSTR szFile)
|
||||||
|
|
||||||
CHMInfo *ret = hhctrl_alloc_zero(sizeof(CHMInfo));
|
CHMInfo *ret = hhctrl_alloc_zero(sizeof(CHMInfo));
|
||||||
|
|
||||||
ret->szFile = szFile;
|
ret->szFile = strdupW(szFile);
|
||||||
|
|
||||||
hres = CoCreateInstance(&CLSID_ITStorage, NULL, CLSCTX_INPROC_SERVER,
|
hres = CoCreateInstance(&CLSID_ITStorage, NULL, CLSCTX_INPROC_SERVER,
|
||||||
&IID_IITStorage, (void **) &ret->pITStorage) ;
|
&IID_IITStorage, (void **) &ret->pITStorage) ;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "commctrl.h"
|
#include "commctrl.h"
|
||||||
#include "wininet.h"
|
#include "wininet.h"
|
||||||
|
|
||||||
#include "wine/unicode.h"
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
@ -737,7 +736,7 @@ static void HH_InitRequiredControls(DWORD dwControls)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates the whole package */
|
/* Creates the whole package */
|
||||||
static BOOL HH_CreateViewer(HHInfo *pHHInfo)
|
static BOOL CreateViewer(HHInfo *pHHInfo)
|
||||||
{
|
{
|
||||||
HH_CreateFont(pHHInfo);
|
HH_CreateFont(pHHInfo);
|
||||||
|
|
||||||
|
@ -765,7 +764,7 @@ static BOOL HH_CreateViewer(HHInfo *pHHInfo)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HH_Close(HHInfo *info)
|
static void ReleaseHelpViewer(HHInfo *info)
|
||||||
{
|
{
|
||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
|
@ -786,43 +785,49 @@ static void HH_Close(HHInfo *info)
|
||||||
CloseCHM(info->pCHMInfo);
|
CloseCHM(info->pCHMInfo);
|
||||||
|
|
||||||
ReleaseWebBrowser(info);
|
ReleaseWebBrowser(info);
|
||||||
|
|
||||||
|
hhctrl_free(info);
|
||||||
|
OleUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static HHInfo *HH_OpenHH(LPWSTR filename)
|
static HHInfo *CreateHelpViewer(LPCWSTR filename)
|
||||||
{
|
{
|
||||||
HHInfo *pHHInfo = hhctrl_alloc_zero(sizeof(HHInfo));
|
HHInfo *info = hhctrl_alloc_zero(sizeof(HHInfo));
|
||||||
|
|
||||||
pHHInfo->pCHMInfo = OpenCHM(filename);
|
OleInitialize(NULL);
|
||||||
if(!pHHInfo->pCHMInfo) {
|
|
||||||
HH_Close(pHHInfo);
|
info->pCHMInfo = OpenCHM(filename);
|
||||||
|
if(!info->pCHMInfo) {
|
||||||
|
ReleaseHelpViewer(info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CHM_LoadWinTypeFromCHM(pHHInfo->pCHMInfo, &pHHInfo->WinType)) {
|
if (!LoadWinTypeFromCHM(info->pCHMInfo, &info->WinType)) {
|
||||||
HH_Close(pHHInfo);
|
ReleaseHelpViewer(info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pHHInfo;
|
if(!CreateViewer(info)) {
|
||||||
|
ReleaseHelpViewer(info);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Check szCmdLine for bad arguments */
|
/* FIXME: Check szCmdLine for bad arguments */
|
||||||
int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
|
int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
HHInfo *pHHInfo;
|
HHInfo *info;
|
||||||
|
LPWSTR filename = strdupAtoW(szCmdLine);
|
||||||
|
|
||||||
if (FAILED(OleInitialize(NULL)))
|
info = CreateHelpViewer(filename);
|
||||||
|
hhctrl_free(filename);
|
||||||
|
if(!info)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pHHInfo = HH_OpenHH(strdupAtoW(szCmdLine));
|
NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszFile);
|
||||||
if (!pHHInfo || !HH_CreateViewer(pHHInfo))
|
|
||||||
{
|
|
||||||
OleUninitialize();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
NavigateToChm(pHHInfo, pHHInfo->pCHMInfo->szFile, pHHInfo->WinType.pszFile);
|
|
||||||
|
|
||||||
while (GetMessageW(&msg, 0, 0, 0))
|
while (GetMessageW(&msg, 0, 0, 0))
|
||||||
{
|
{
|
||||||
|
@ -830,9 +835,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
|
||||||
DispatchMessageW(&msg);
|
DispatchMessageW(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
HH_Close(pHHInfo);
|
ReleaseHelpViewer(info);
|
||||||
hhctrl_free(pHHInfo);
|
|
||||||
OleUninitialize();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2005 James Hawkins
|
* Copyright 2005 James Hawkins
|
||||||
|
* 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
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wine/itss.h"
|
#include "wine/itss.h"
|
||||||
|
#include "wine/unicode.h"
|
||||||
|
|
||||||
#define WB_GOBACK 0
|
#define WB_GOBACK 0
|
||||||
#define WB_GOFORWARD 1
|
#define WB_GOFORWARD 1
|
||||||
|
@ -75,7 +77,7 @@ void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
|
||||||
void DoPageAction(HHInfo*,DWORD);
|
void DoPageAction(HHInfo*,DWORD);
|
||||||
|
|
||||||
CHMInfo *OpenCHM(LPCWSTR szFile);
|
CHMInfo *OpenCHM(LPCWSTR szFile);
|
||||||
BOOL CHM_LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
|
BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
|
||||||
CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
|
CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
|
||||||
|
|
||||||
/* memory allocation functions */
|
/* memory allocation functions */
|
||||||
|
@ -105,6 +107,21 @@ static inline BOOL hhctrl_free(void *mem)
|
||||||
return HeapFree(GetProcessHeap(), 0, mem);
|
return HeapFree(GetProcessHeap(), 0, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline LPWSTR strdupW(LPCWSTR str)
|
||||||
|
{
|
||||||
|
LPWSTR ret;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if(!str)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
size = (strlenW(str)+1)*sizeof(WCHAR);
|
||||||
|
ret = hhctrl_alloc(size);
|
||||||
|
memcpy(ret, str, size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static inline LPWSTR strdupAtoW(LPCSTR str)
|
static inline LPWSTR strdupAtoW(LPCSTR str)
|
||||||
{
|
{
|
||||||
LPWSTR ret;
|
LPWSTR ret;
|
||||||
|
|
Loading…
Reference in New Issue