views:

189

answers:

3

I have an ActiveX control written in C++ that I created with VS2008 and ATL. For the most part, it is a pretty standard (not modified much from the original template) control, except that instead of using IDispatchImpl, I have created my own IDispatchEx implementation. This control is only used in Internet Explorer, and I have been testing primarily with IE8.

Everything works great, except that for some reason, InPlaceActivate doesn't get called until I move the mouse over the region where the object tag is hosted in the browser; no window is created, no WM_CREATE message sent, etc.

I have tried implementing DISPID_READYSTATE, but nothing seems to help. If I call InPlaceActivate(OLEIVERB_UIACTIVATE); from the SetClientSite method and it usually works, but that certainly isn't normally neccesary.

Why would this happen? How does the browser determine when to call InPlaceActivate (or whatever call triggers that)?

The tag used to embed the ATL control into the page is: <object id="plugin" type="application/x-vnd.FirebreathTemplatePlugin" width="300" height="300"></object>

You full source to the file can be found here: http://code.google.com/p/firebreath/source/browse/src/ActiveXPlugin/FBControl.h

+1  A: 

Have you tried returning OLEMISC_ACTIVATEWHENVISIBLE inside your IOleObject::GetMiscStatus() implementation?

jeffamaphone
From the default ATL class, I have this still there:DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE | OLEMISC_CANTLINKINSIDE | OLEMISC_INSIDEOUT | OLEMISC_ACTIVATEWHENVISIBLE | OLEMISC_SETCLIENTSITEFIRST)Is there anything that I could be doing to inadvertently override that?
Taxilian
Sorry, I'm not sure. That was my best guess.
jeffamaphone
+1  A: 

If all you want is to ensure your window created for scripting, you can create the window earlier, as described in PRB: ActiveX Control Window Is Not Created Until Visible in Internet Explorer

See also IE Automatic Component Activation (Changes to IE ActiveX Update)

Sheng Jiang 蒋晟
I have looked at that; I guess it would be better than nothing, but I have created other ATL controls, and I have never needed to do this before. As is essentially specified in the document you referenced, InPlaceActivate should get called as soon as the control is visible; it is not getting called until I move the mouse over the region where it is drawn.From the article (which I've read before) it sounds like it might be a windowless control by default; however, the first line of the contructor is:m_bWindowOnly = TRUE;and I never change the value after that.
Taxilian
A: 

I found the culprit. Aparently, the OLEMSIC_ACTIVATEWHENVISIBLE is used to auto-generate the %OLEMISC% variable in the .rgs file. However, I had overridden the default rgs handling to provide my own variables, and in the process one critical line got removed, which would have added a:

[CLSID]/MiscStatus/1 = s '131473'

to the registry. this aparently is used by the browser to decide how to initialize, and that value has OLEMISC_ACTIVATEWHENVISIBLE 'or'ed (|) into it. Added that back in and everything works again.

Taxilian