From 97bcef997fdd53137ab250448ac15bb9d4b40ee3 Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Thu, 12 Jul 2012 10:21:36 -0600 Subject: [PATCH] hhctrl.ocx: Implement HH_CLOSE_ALL. --- dlls/hhctrl.ocx/chm.c | 6 ++++-- dlls/hhctrl.ocx/help.c | 5 +++++ dlls/hhctrl.ocx/hhctrl.c | 31 +++++++++++++++++++++++++------ dlls/hhctrl.ocx/hhctrl.h | 3 +++ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c index cc92b89425e..82b8d9a6dc1 100644 --- a/dlls/hhctrl.ocx/chm.c +++ b/dlls/hhctrl.ocx/chm.c @@ -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); diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c index 87ea94fc41e..2f2fba1e417 100644 --- a/dlls/hhctrl.ocx/help.c +++ b/dlls/hhctrl.ocx/help.c @@ -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; } diff --git a/dlls/hhctrl.ocx/hhctrl.c b/dlls/hhctrl.ocx/hhctrl.c index 7647abb085b..a5e7e3713ea 100644 --- a/dlls/hhctrl.ocx/hhctrl.c +++ b/dlls/hhctrl.ocx/hhctrl.c @@ -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 )); } diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h index 8959748e28c..f03d4768ee2 100644 --- a/dlls/hhctrl.ocx/hhctrl.h +++ b/dlls/hhctrl.ocx/hhctrl.h @@ -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;