Signed-off-by: Gabriel Ivăncescu gabrielopcode@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 845d501..a617634 100644 --- a/dlls/msscript.ocx/msscript.c +++ b/dlls/msscript.ocx/msscript.c @@ -147,6 +147,7 @@ struct ScriptHost { IActiveScript *script; IActiveScriptParse *parse; ScriptError *error; + HWND site_hwnd; SCRIPTSTATE script_state; CLSID clsid;
@@ -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 == ((HWND)-1)) return E_FAIL; + + *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 ? control->site_hwnd : ((HWND)-1); 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 = LongToHandle(hwnd); + if (This->host) + This->host->site_hwnd = This->allow_ui ? This->site_hwnd : ((HWND)-1); 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 ? This->site_hwnd : ((HWND)-1); 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); }