[PATCH 4/6] msscript.ocx: Implement IActiveScriptSiteWindow::GetWindow.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Wed Sep 2 08:01:09 CDT 2020
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
We keep a copy of the site_hwnd since the function works even without the
control (it just can't be changed anymore), see last test.
dlls/msscript.ocx/msscript.c | 14 ++++++++++++--
dlls/msscript.ocx/tests/msscript.c | 24 ++++++++++++------------
2 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/dlls/msscript.ocx/msscript.c b/dlls/msscript.ocx/msscript.c
index 55a5621..67d894d 100644
--- a/dlls/msscript.ocx/msscript.c
+++ b/dlls/msscript.ocx/msscript.c
@@ -148,6 +148,7 @@ struct ScriptHost {
IActiveScriptParse *parse;
ScriptError *error;
SCRIPTSTATE script_state;
+ LONG site_hwnd;
CLSID clsid;
unsigned int module_count;
@@ -761,9 +762,13 @@ static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow *
{
ScriptHost *This = impl_from_IActiveScriptSiteWindow(iface);
- FIXME("(%p, %p)\n", This, hwnd);
+ TRACE("(%p, %p)\n", This, hwnd);
- return E_NOTIMPL;
+ if (!hwnd) return E_POINTER;
+ if (This->site_hwnd == -1) return E_FAIL;
+
+ *hwnd = (HWND)This->site_hwnd;
+ return S_OK;
}
static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow *iface, BOOL enable)
@@ -2481,6 +2486,7 @@ static HRESULT init_script_host(ScriptControl *control, const CLSID *clsid, Scri
goto failed;
}
host->script_state = SCRIPTSTATE_INITIALIZED;
+ host->site_hwnd = (control->allow_ui == VARIANT_FALSE) ? -1 : control->site_hwnd;
host->error = control->error;
IScriptError_AddRef(&host->error->IScriptError_iface);
@@ -2758,6 +2764,8 @@ static HRESULT WINAPI ScriptControl_put_SitehWnd(IScriptControl *iface, LONG hwn
return CTL_E_INVALIDPROPERTYVALUE;
This->site_hwnd = hwnd;
+ if (This->host)
+ This->host->site_hwnd = (This->allow_ui == VARIANT_FALSE) ? -1 : hwnd;
return S_OK;
}
@@ -2820,6 +2828,8 @@ static HRESULT WINAPI ScriptControl_put_AllowUI(IScriptControl *iface, VARIANT_B
TRACE("(%p)->(%x)\n", This, allow_ui);
This->allow_ui = allow_ui;
+ if (This->host)
+ This->host->site_hwnd = (allow_ui == VARIANT_FALSE) ? -1 : This->site_hwnd;
return S_OK;
}
diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c
index 8e4fa1b..2df85ff 100644
--- a/dlls/msscript.ocx/tests/msscript.c
+++ b/dlls/msscript.ocx/tests/msscript.c
@@ -1994,10 +1994,10 @@ static void test_SitehWnd(void)
window = NULL;
hr = IActiveScriptSiteWindow_GetWindow(site_window, NULL);
- todo_wine ok(hr == E_POINTER, "got 0x%08x\n", hr);
+ ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IActiveScriptSiteWindow_GetWindow(site_window, &window);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- todo_wine ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
hr = IActiveScriptSiteWindow_EnableModeless(site_window, FALSE);
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -2013,8 +2013,8 @@ static void test_SitehWnd(void)
window = (HWND)0xdeadbeef;
hr = IActiveScriptSiteWindow_GetWindow(site_window, &window);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- todo_wine ok(!window, "got %p\n", window);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(!window, "got %p\n", window);
site_hwnd = 0;
hr = IScriptControl_put_SitehWnd(sc, (LONG)(LONG_PTR)hwnd);
@@ -2025,8 +2025,8 @@ static void test_SitehWnd(void)
window = NULL;
hr = IActiveScriptSiteWindow_GetWindow(site_window, &window);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- todo_wine ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
hr = IScriptControl_put_AllowUI(sc, VARIANT_FALSE);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -2037,7 +2037,7 @@ static void test_SitehWnd(void)
window = NULL;
hr = IActiveScriptSiteWindow_GetWindow(site_window, &window);
- todo_wine ok(hr == E_FAIL, "got 0x%08x\n", hr);
+ ok(hr == E_FAIL, "got 0x%08x\n", hr);
ok(!window, "got %p\n", window);
hr = IScriptControl_put_AllowUI(sc, VARIANT_TRUE);
@@ -2045,8 +2045,8 @@ static void test_SitehWnd(void)
window = NULL;
hr = IActiveScriptSiteWindow_GetWindow(site_window, &window);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- todo_wine ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
IActiveScriptSite_Release(site);
@@ -2056,8 +2056,8 @@ static void test_SitehWnd(void)
window = NULL;
hr = IActiveScriptSiteWindow_GetWindow(site_window, &window);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
- todo_wine ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(window == hwnd, "got %p, expected %p\n", window, hwnd);
IActiveScriptSiteWindow_Release(site_window);
}
--
2.21.0
More information about the wine-devel
mailing list