I’m trying to do what they explain on this article in the Controlling Download and Execution section. I understand the Web Browser Control in that context is not .NET’s WebBrowser.
What I’m trying to do is to gain control over what the WebBrowser control downloads. I’ve been searching for this a lot and always en up in the csEXWB, which has a huge code that I just cannot decipher.
What I’ve done so far is inherit .NET’s WebBrowser, make my inherited class com visible by using the [ComVisible(true)] attribute, add this method to my class (taken from csEXWB):
[DispId(HTMLDispIDs.DISPID_AMBIENT_DLCONTROL)]
public int Idispatch_AmbiantDlControl_Invoke_Handler()
{
return (int)m_DLCtlFlags;
}
And then call this line of code, where Browser is an instance of my derived class:
IfacesEnumsStructsClasses.IOleControl oleControl = Browser.ActiveXInstance as IfacesEnumsStructsClasses.IOleControl;
oleControl.OnAmbientPropertyChange(IfacesEnumsStructsClasses.HTMLDispIDs.DISPID_AMBIENT_DLCONTROL);
So what I’m hoping is that the oleControl will call my Idispatch_AmbiantDlControl_Invoke_Handler method, which it doesn’t. I don’t know how, and this is probably what my code is missing, is the oleControl supposed to know on which object to call my Idispatch_AmbiantDlControl_Invoke_Handler method.
What the article I linked above says is it will call your IDispatch::Invoke. What does it mean by your. How do I tell oleControl which object is my IDispatch. Hope I’m making any sense.
Here is a customized WebBrowser that allows you to change the DLCONTROL flags.
This is an example code:
And the customized WebBrowser code: