hhctrl.ocx: Implement HH_CLOSE_ALL.

This commit is contained in:
Erich Hoover 2012-07-12 10:21:36 -06:00 committed by Alexandre Julliard
parent 5a45e34741
commit 97bcef997f
4 changed files with 37 additions and 8 deletions

View file

@ -138,7 +138,8 @@ static BOOL ReadChmSystem(CHMInfo *chm)
chm->codePage = CP_ACP;
break;
case 0x5:
TRACE("Default window is %s\n", debugstr_an(buf, entry.len));
TRACE("Window name is %s\n", debugstr_an(buf, entry.len));
chm->defWindow = strdupnAtoW(buf, entry.len);
break;
case 0x6:
TRACE("Compiled file is %s\n", debugstr_an(buf, entry.len));
@ -268,7 +269,7 @@ BOOL LoadWinTypeFromCHM(HHInfo *info)
memset((void*)&(info->WinType), 0, sizeof(info->WinType));
info->WinType.cbStruct=sizeof(info->WinType);
info->WinType.fUniCodeStrings=TRUE;
info->WinType.pszType=strdupW(defaultwinW);
info->WinType.pszType = strdupW(info->pCHMInfo->defWindow ? info->pCHMInfo->defWindow : defaultwinW);
info->WinType.pszToc = strdupW(info->pCHMInfo->defToc ? info->pCHMInfo->defToc : null);
info->WinType.pszIndex = strdupW(null);
info->WinType.fsValidMembers=0;
@ -530,6 +531,7 @@ CHMInfo *CloseCHM(CHMInfo *chm)
}
heap_free(chm->strings);
heap_free(chm->defWindow);
heap_free(chm->defTitle);
heap_free(chm->defTopic);
heap_free(chm->defToc);

View file

@ -48,6 +48,8 @@ static void ExpandContract(HHInfo *pHHInfo);
#define TAB_MARGIN 8
#define EDIT_HEIGHT 20
struct list window_list = LIST_INIT(window_list);
static const WCHAR szEmpty[] = {0};
struct html_encoded_symbol {
@ -1740,6 +1742,8 @@ void ReleaseHelpViewer(HHInfo *info)
if (!info)
return;
list_remove(&info->entry);
/* Free allocated strings */
heap_free(info->pszType);
heap_free(info->pszCaption);
@ -1798,6 +1802,7 @@ HHInfo *CreateHelpViewer(LPCWSTR filename)
return NULL;
}
list_add_tail(&window_list, &info->entry);
return info;
}

View file

@ -41,6 +41,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
HINSTANCE hhctrl_hinstance;
BOOL hh_process = FALSE;
extern struct list window_list;
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(%p,%d,%p)\n", hInstance, fdwReason, lpvReserved);
@ -98,7 +100,7 @@ static const char *command_to_string(UINT command)
#undef X
}
static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen, const WCHAR **index, const WCHAR **window)
static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
{
const WCHAR *extra;
WCHAR chm_file[MAX_PATH];
@ -164,14 +166,15 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
HHInfo *info;
BOOL res;
NMHDR nmhdr;
WCHAR *window = NULL;
const WCHAR *index = NULL;
WCHAR *default_index = NULL;
int tab_index = TAB_CONTENTS;
const WCHAR *default_index = NULL;
if (!filename)
return NULL;
if (!resolve_filename(filename, fullname, MAX_PATH, &default_index, NULL))
if (!resolve_filename(filename, fullname, MAX_PATH, &default_index, &window))
{
WARN("can't find %s\n", debugstr_w(filename));
return 0;
@ -180,10 +183,18 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
info = CreateHelpViewer(fullname);
if(!info)
{
heap_free(default_index);
heap_free(window);
return NULL;
}
if(!index)
index = info->WinType.pszFile;
if(!info->pszType)
info->WinType.pszType = info->pszType = window;
else
heap_free(window);
/* called to load a specified topic */
switch(command)
@ -196,9 +207,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
}
res = NavigateToChm(info, info->pCHMInfo->szFile, index);
if (default_index)
heap_free((WCHAR*)default_index);
heap_free(default_index);
if(!res)
{
@ -269,6 +278,16 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
}
return 0;
}
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;
}
default:
FIXME("HH case %s not handled.\n", command_to_string( command ));
}

View file

@ -40,6 +40,7 @@
#include "wine/itss.h"
#include "wine/unicode.h"
#include "wine/list.h"
#define WB_GOBACK 0
#define WB_GOFORWARD 1
@ -103,6 +104,7 @@ typedef struct CHMInfo
DWORD strings_size;
WCHAR *compiledFile;
WCHAR *defWindow;
WCHAR *defTopic;
WCHAR *defTitle;
WCHAR *defToc;
@ -157,6 +159,7 @@ typedef struct {
LPWSTR pszUrlJump2;
LPWSTR pszCustomTabs;
struct list entry;
CHMInfo *pCHMInfo;
ContentItem *content;
IndexItem *index;