pop-up manager and the webbrowser control
If you are hosting the webbrowser control, here is how you interact with IE's pop-up manager:
Implement INewWindowManager (beta documentation; not final). This should be implemented by the same object that implements IDocHostUIHandler.
When mshtml detects a new window is being requested, it will call INWM::EvaluateNewWindow(). Here is some boiler-plate for you:
I do not want pop-up management
This is the easy case, since pop-up management is opt-in. Simply do nothing. The webbrowser control will query you for INWM. If the query fails, no pop-up management will occur.
I just want the same pop-up management that IE has
This is easy too. Simply implement INWM::ENW() and return E_NOTIMPL:
CMyObject::EvaluateNewWindow(...)
{
return E_NOTIMPL;
}
When the webbrowser control sees the failure code, it will fall back to the default pop-up management.
I want to implement my own logic
Implement INWM::ENW() and use the parameters to decide whether or not to block the new window. Return S_FALSE to block the window and S_OK to allow it:
CMyObject::EvaluateNewWindow(...)
{
HRESULT hr = S_OK;
if (/* your logic here */)
{
hr = S_FALSE;
}
else if (/* more of your logic here */)
{
hr = S_FALSE;
}
// ... and so on ...
// Now update your UI.
switch(hr)
{
case S_OK:
OnPopupNotBlocked(...);
break;
case S_FALSE:
OnPopupBlocked(...);
break;
}
return hr;
}