diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c
index 8f280c5f5db..9ab0983080b 100644
--- a/dlls/mshtml/pluginhost.c
+++ b/dlls/mshtml/pluginhost.c
@@ -651,8 +651,36 @@ static HRESULT WINAPI PHInPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
static HRESULT WINAPI PHInPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
{
PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
- FIXME("(%p)\n", This);
- return E_NOTIMPL;
+ DISPPARAMS args = {NULL, NULL, 0, 0};
+ IDispatch *disp;
+ ULONG err = 0;
+ VARIANT res;
+ HRESULT hres;
+
+ TRACE("(%p)\n", This);
+
+ if(!This->plugin_unk) {
+ ERR("No plugin object\n");
+ return E_UNEXPECTED;
+ }
+
+ This->ui_active = TRUE;
+
+ hres = IUnknown_QueryInterface(This->plugin_unk, &IID_IDispatch, (void**)&disp);
+ if(FAILED(hres)) {
+ FIXME("Could not get IDispatch iface: %08x\n", hres);
+ return hres;
+ }
+
+ V_VT(&res) = VT_EMPTY;
+ hres = IDispatch_Invoke(disp, DISPID_ENABLED, &IID_NULL, 0/*FIXME*/, DISPATCH_PROPERTYGET, &args, &res, NULL, &err);
+ IDispatch_Release(disp);
+ if(SUCCEEDED(hres)) {
+ FIXME("Got enabled %s\n", debugstr_variant(&res));
+ VariantClear(&res);
+ }
+
+ return S_OK;
}
static HRESULT WINAPI PHInPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
@@ -1024,8 +1052,11 @@ void detach_plugin_host(PluginHost *host)
if(!host->doc)
return;
- if(host->ip_object)
+ if(host->ip_object) {
+ if(host->ui_active)
+ IOleInPlaceObject_UIDeactivate(host->ip_object);
IOleInPlaceObject_InPlaceDeactivate(host->ip_object);
+ }
if(host->plugin_unk) {
IOleObject *ole_obj;
diff --git a/dlls/mshtml/pluginhost.h b/dlls/mshtml/pluginhost.h
index c547946903d..65ccb60578f 100644
--- a/dlls/mshtml/pluginhost.h
+++ b/dlls/mshtml/pluginhost.h
@@ -33,8 +33,10 @@ typedef struct {
IUnknown *plugin_unk;
IOleInPlaceObject *ip_object;
CLSID clsid;
+
HWND hwnd;
RECT rect;
+ BOOL ui_active;
HTMLDocumentNode *doc;
struct list entry;
diff --git a/dlls/mshtml/tests/activex.c b/dlls/mshtml/tests/activex.c
index aab13d5be07..a89d7e7702f 100644
--- a/dlls/mshtml/tests/activex.c
+++ b/dlls/mshtml/tests/activex.c
@@ -63,6 +63,8 @@ DEFINE_EXPECT(QuickActivate);
DEFINE_EXPECT(IPersistPropertyBag_InitNew);
DEFINE_EXPECT(IPersistPropertyBag_Load);
DEFINE_EXPECT(Invoke_READYSTATE);
+DEFINE_EXPECT(Invoke_ENABLED);
+DEFINE_EXPECT(Invoke_VALID);
DEFINE_EXPECT(DoVerb);
DEFINE_EXPECT(SetExtent);
DEFINE_EXPECT(GetExtent);
@@ -72,6 +74,7 @@ DEFINE_EXPECT(Close);
DEFINE_EXPECT(InPlaceObject_GetWindow);
DEFINE_EXPECT(SetObjectRects);
DEFINE_EXPECT(InPlaceDeactivate);
+DEFINE_EXPECT(UIDeactivate);
static HWND container_hwnd, plugin_hwnd;
@@ -572,6 +575,18 @@ static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REF
V_VT(pVarResult) = VT_I4;
V_I4(pVarResult) = plugin_readystate;
return S_OK;
+ case DISPID_ENABLED:
+ CHECK_EXPECT2(Invoke_ENABLED);
+ ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
+ ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
+ ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
+ return DISP_E_MEMBERNOTFOUND;
+ case DISPID_VALID:
+ CHECK_EXPECT(Invoke_VALID);
+ ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
+ ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
+ ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
+ return DISP_E_MEMBERNOTFOUND;
default:
ok(0, "unexpected call %d\n", dispIdMember);
}
@@ -1003,8 +1018,8 @@ static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObjectWindow
static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObjectWindowless *iface)
{
- ok(0, "unexpected call\n");
- return E_NOTIMPL;
+ CHECK_EXPECT2(UIDeactivate);
+ return S_OK;
}
static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObjectWindowless *iface,
@@ -1149,6 +1164,22 @@ static const IClassFactoryVtbl ClassFactoryVtbl = {
static IClassFactory activex_cf = { &ClassFactoryVtbl };
+static void test_ui_activate(void)
+{
+ IOleInPlaceSite *ip_site;
+ HRESULT hres;
+
+ hres = IOleClientSite_QueryInterface(client_site, &IID_IOleInPlaceSite, (void**)&ip_site);
+ ok(hres == S_OK, "Could not get IOleInPlaceSite iface: %08x\n", hres);
+
+ SET_EXPECT(Invoke_ENABLED);
+ hres = IOleInPlaceSite_OnUIActivate(ip_site);
+ ok(hres == S_OK, "OnUIActivate failed: %08x\n", hres);
+ CHECK_CALLED(Invoke_ENABLED);
+
+ IOleInPlaceSite_Release(ip_site);
+}
+
static HRESULT cs_qi(REFIID,void **);
static IOleDocumentView *view;
@@ -1747,10 +1778,20 @@ static void test_object_ax(void)
CHECK_CALLED(InPlaceObject_GetWindow);
CHECK_CALLED(SetObjectRects);
+ test_ui_activate();
+
+ SET_EXPECT(UIDeactivate);
+ SET_EXPECT(Invoke_ENABLED);
+ SET_EXPECT(Invoke_VALID);
SET_EXPECT(InPlaceDeactivate);
SET_EXPECT(Close);
SET_EXPECT(SetClientSite_NULL);
release_doc(doc);
+ CHECK_CALLED(UIDeactivate);
+ todo_wine
+ CHECK_CALLED(Invoke_ENABLED);
+ todo_wine
+ CHECK_CALLED(Invoke_VALID);
CHECK_CALLED(InPlaceDeactivate);
CHECK_CALLED(Close);
CHECK_CALLED(SetClientSite_NULL);