Search code examples
delphicomoletwebbrowsershdocvw

Updated TWebBrowser now implements IDocUIHandler from the start, how can I keep using my custom implementation?


Beginning with Delphi 10.0 Seattle, Embarcadero has changed the implementation of the TWebBrowser control:

Pre-Seattle: TWebBrowser = class(TOleControl)

Seattle+: TWebBrowser = class(TOleControl, IDocHostUIHandler, IDocHostShowUI, IOleCommandTarget)

I have somewhat old code running where I had implemented a class that could register as a client site/host for a TWebBrowser where I provided my own implementation of the IDocHostUIHandler interface.

Since a TWebBrowser is now implementing these from the start (and keeping them private) and is hard to descend from for all I know - how do I go about to get the new TWebBrowser component to re-register where to find an implementation for IDocHostUIHandler?


Solution

  • You can descend from TWebBrowser and provide your own interface definitions as before, like this:

    Type
      TMyWebBrower = class( TWebBrowser, IDocHostUIHandler )
      ...
      end;
    

    This tells Delphi that you are reimplementing the IDocHostUIHandler interface. You must provide all functions for the interface, but you already have that.