
BHO's don't seem to get window resize messages. I would expect my Invoke() function would be called with DISPID_WINDOWRESIZE when I mouse-drag the main IE window's corner (or otherwise alter the size), but I never see that message coming in.
case DISPID_WINDOWMOVE: case DISPID_WINDOWRESIZE: {
OutputDebugStringW(L"This never gets called!");
} break;
It's up at http://petesearch.com/ResizeBHOBug.zip
When I build and run it, with a breakpoint on the debug logging line, I never see that message coming in.
I've got a forum post up covering this issue, with no responses.
I need to do this so I can keep the split-screen child window at the correct size in PeteSearch. To work around the lack of messages, I resorted to calling SetWindowsHookEx() on the main browser window, catching resize messages and calling my child window explicitly, before passing them onto the normal IE message handler. Needless to say, this is not ideal, and I suspect is the reason that my BHO won't run correctly on IE6.
Update
Thanks to LiuCougar and Katrine Larsen there's now a better solution.
LiuCougar? suggested the right way to handle this originally:
I just wanted to say that, you should be getting DISPID_HTMLWINDOWEVENTS_ONRESIZE event correctly in your BHO ( http://msdn2.microsoft.com/en-us/library/aa741886(VS.85).aspx ), if you connect to IHTMLWindow events in your BHO
Katrine tested that suggestion, and was kind enough to send on a function that implemented it:
void CMyBHO::AdviseFrameEvents(IDispatch* _pElem, const IID _iid)
{
HRESULT hr;
IConnectionPointContainer* pCPC = NULL;
IConnectionPoint* pCP = NULL;
DWORD dwCookie;
// Check that this is a connectable object.
hr = _pElem->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
if (SUCCEEDED(hr))
{
// Find the connection point.
hr = pCPC->FindConnectionPoint(_iid, &pCP);
if (SUCCEEDED(hr))
{
// Advise the connection point.
// pUnk is the IUnknown interface pointer for yourevent sink
hr = pCP->Advise(reinterpret_cast<IDispatch*>(this), &dwCookie);
if (SUCCEEDED(hr))
{
// Successfully advised
m_connection_points.push_back(pCP);
m_advise_cookies.push_back(dwCookie);
}
pCP->Release();
}
pCPC->Release();
}
}