Erich Hoover : hhctrl.ocx: Implement HH_GET_WIN_TYPE.
Alexandre Julliard
julliard at winehq.org
Tue Sep 4 12:38:38 CDT 2012
Module: wine
Branch: master
Commit: af0fa40effda14c124a4cb619f66830cfe2f7773
URL: http://source.winehq.org/git/wine.git/?a=commit;h=af0fa40effda14c124a4cb619f66830cfe2f7773
Author: Erich Hoover <ehoover at mines.edu>
Date: Fri Aug 31 15:26:12 2012 -0600
hhctrl.ocx: Implement HH_GET_WIN_TYPE.
---
dlls/hhctrl.ocx/help.c | 16 +++++++++++
dlls/hhctrl.ocx/hhctrl.c | 66 +++++++++++++++++++++++++++++++++++++++------
dlls/hhctrl.ocx/hhctrl.h | 29 ++++++++++++++++++++
3 files changed, 102 insertions(+), 9 deletions(-)
diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c
index 6671f70..93a93a5 100644
--- a/dlls/hhctrl.ocx/help.c
+++ b/dlls/hhctrl.ocx/help.c
@@ -1757,6 +1757,21 @@ void wintype_stringsW_free(struct wintype_stringsW *stringsW)
heap_free(stringsW->pszUrlJump2);
}
+void wintype_stringsA_free(struct wintype_stringsA *stringsA)
+{
+ heap_free(stringsA->pszType);
+ heap_free(stringsA->pszCaption);
+ heap_free(stringsA->pszToc);
+ heap_free(stringsA->pszIndex);
+ heap_free(stringsA->pszFile);
+ heap_free(stringsA->pszHome);
+ heap_free(stringsA->pszJump1);
+ heap_free(stringsA->pszJump2);
+ heap_free(stringsA->pszUrlJump1);
+ heap_free(stringsA->pszUrlJump2);
+ heap_free(stringsA->pszCustomTabs);
+}
+
void ReleaseHelpViewer(HHInfo *info)
{
TRACE("(%p)\n", info);
@@ -1766,6 +1781,7 @@ void ReleaseHelpViewer(HHInfo *info)
list_remove(&info->entry);
+ wintype_stringsA_free(&info->stringsA);
wintype_stringsW_free(&info->stringsW);
if (info->pCHMInfo)
diff --git a/dlls/hhctrl.ocx/hhctrl.c b/dlls/hhctrl.ocx/hhctrl.c
index 4ed9afc..7f11276 100644
--- a/dlls/hhctrl.ocx/hhctrl.c
+++ b/dlls/hhctrl.ocx/hhctrl.c
@@ -330,6 +330,29 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
MergeChmProperties(wintype, info);
return 0;
}
+ case HH_GET_WIN_TYPE: {
+ HH_WINTYPEW *wintype = (HH_WINTYPEW *)data;
+ WCHAR *window = NULL;
+ HHInfo *info = NULL;
+
+ if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
+ {
+ WARN("can't find window name: %s\n", debugstr_w(filename));
+ return 0;
+ }
+ info = find_window(window);
+ if (!info)
+ {
+ WARN("Could not find window named %s.\n", debugstr_w(window));
+ heap_free(window);
+ return (HWND)~0;
+ }
+
+ TRACE("Retrieving WINTYPE for %s.\n", debugstr_w(window));
+ *wintype = info->WinType;
+ heap_free(window);
+ return 0;
+ }
default:
FIXME("HH case %s not handled.\n", command_to_string( command ));
}
@@ -337,11 +360,8 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
return 0;
}
-static HH_WINTYPEW *wintypeAtoW(HH_WINTYPEA *data, struct wintype_stringsW *stringsW)
+static void wintypeAtoW(const HH_WINTYPEA *data, HH_WINTYPEW *wdata, struct wintype_stringsW *stringsW)
{
- HH_WINTYPEW *wdata;
-
- wdata = heap_alloc(sizeof(*wdata));
memcpy(wdata, data, sizeof(*data));
/* convert all of the ANSI strings to Unicode */
wdata->pszType = stringsW->pszType = strdupAtoW(data->pszType);
@@ -355,8 +375,23 @@ static HH_WINTYPEW *wintypeAtoW(HH_WINTYPEA *data, struct wintype_stringsW *stri
wdata->pszUrlJump1 = stringsW->pszUrlJump1 = strdupAtoW(data->pszUrlJump1);
wdata->pszUrlJump2 = stringsW->pszUrlJump2 = strdupAtoW(data->pszUrlJump2);
wdata->pszCustomTabs = stringsW->pszCustomTabs = strdupAtoW(data->pszCustomTabs);
+}
- return wdata;
+static void wintypeWtoA(const HH_WINTYPEW *wdata, HH_WINTYPEA *data, struct wintype_stringsA *stringsA)
+{
+ memcpy(data, wdata, sizeof(*wdata));
+ /* convert all of the Unicode strings to ANSI */
+ data->pszType = stringsA->pszType = strdupWtoA(wdata->pszType);
+ data->pszCaption = stringsA->pszCaption = strdupWtoA(wdata->pszCaption);
+ data->pszToc = stringsA->pszToc = strdupWtoA(wdata->pszToc);
+ data->pszIndex = stringsA->pszFile = strdupWtoA(wdata->pszIndex);
+ data->pszFile = stringsA->pszFile = strdupWtoA(wdata->pszFile);
+ data->pszHome = stringsA->pszHome = strdupWtoA(wdata->pszHome);
+ data->pszJump1 = stringsA->pszJump1 = strdupWtoA(wdata->pszJump1);
+ data->pszJump2 = stringsA->pszJump2 = strdupWtoA(wdata->pszJump2);
+ data->pszUrlJump1 = stringsA->pszUrlJump1 = strdupWtoA(wdata->pszUrlJump1);
+ data->pszUrlJump2 = stringsA->pszUrlJump2 = strdupWtoA(wdata->pszUrlJump2);
+ data->pszCustomTabs = stringsA->pszCustomTabs = strdupWtoA(wdata->pszCustomTabs);
}
/******************************************************************
@@ -375,7 +410,6 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
case HH_DISPLAY_SEARCH:
case HH_DISPLAY_TEXT_POPUP:
case HH_GET_LAST_ERROR:
- case HH_GET_WIN_TYPE:
case HH_KEYWORD_LOOKUP:
case HH_SYNC:
FIXME("structures not handled yet\n");
@@ -384,10 +418,24 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
case HH_SET_WIN_TYPE:
{
struct wintype_stringsW stringsW;
- HH_WINTYPEW *wdata = wintypeAtoW((HH_WINTYPEA *)data, &stringsW);
- result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)wdata );
+ HH_WINTYPEW wdata;
+
+ wintypeAtoW((HH_WINTYPEA *)data, &wdata, &stringsW);
+ result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
wintype_stringsW_free(&stringsW);
- heap_free( wdata );
+ goto done;
+ }
+ case HH_GET_WIN_TYPE:
+ {
+ HH_WINTYPEW wdata;
+ HHInfo *info;
+
+ result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)&wdata );
+ if (!wdata.pszType) break;
+ info = find_window(wdata.pszType);
+ if (!info) break;
+ wintype_stringsA_free(&info->stringsA);
+ wintypeWtoA(&wdata, (HH_WINTYPEA *)data, &info->stringsA);
goto done;
}
diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h
index 900bbb4..7bdf26e 100644
--- a/dlls/hhctrl.ocx/hhctrl.h
+++ b/dlls/hhctrl.ocx/hhctrl.h
@@ -154,6 +154,20 @@ struct wintype_stringsW {
WCHAR *pszCustomTabs;
};
+struct wintype_stringsA {
+ char *pszType;
+ char *pszCaption;
+ char *pszToc;
+ char *pszIndex;
+ char *pszFile;
+ char *pszHome;
+ char *pszJump1;
+ char *pszJump2;
+ char *pszUrlJump1;
+ char *pszUrlJump2;
+ char *pszCustomTabs;
+};
+
typedef struct {
IOleClientSite *client_site;
IWebBrowser2 *web_browser;
@@ -161,6 +175,7 @@ typedef struct {
HH_WINTYPEW WinType;
+ struct wintype_stringsA stringsA;
struct wintype_stringsW stringsW;
struct list entry;
@@ -209,6 +224,7 @@ void InitSearch(HHInfo *info, const char *needle) DECLSPEC_HIDDEN;
void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN;
+void wintype_stringsA_free(struct wintype_stringsA *stringsA) DECLSPEC_HIDDEN;
void wintype_stringsW_free(struct wintype_stringsW *stringsW) DECLSPEC_HIDDEN;
WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page);
@@ -282,6 +298,19 @@ static inline LPWSTR strdupAtoW(LPCSTR str)
return strdupnAtoW(str, -1);
}
+static inline LPSTR strdupWtoA(LPCWSTR str)
+{
+ LPSTR ret;
+ DWORD len;
+
+ if(!str)
+ return NULL;
+
+ len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
+ ret = heap_alloc(len);
+ WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
+ return ret;
+}
extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list