Your attempt to use Load
method for loading a page was correct. The other one was wrong and failed because the Browser
instance was not created. It's because the TChromiumOSR
was designed to be a design time component rather than to be created dynamically.
Now, the only place where the Browser
instance is created is the Loaded
method, which is called for a component after its parent form is loaded from a stream. And since you are creating it dynamically, the Browser
instance is never created.
For some reason also the CreateBrowser
method (which creates the Browser
instance) is declared as private, which complicates its calling a bit (unless you decide to modify the source and make it public). If you don't want to change your DCEF source code, you can use a class helper to provide access to the CreateBrowser
method:
uses
ceflib, cefvcl;
type
TChromiumOSRHelper = class helper for TCustomChromiumOSR
public
procedure CreateBrowserInstance;
end;
implementation
{ TChromiumOSRHelper }
procedure TChromiumOSRHelper.CreateBrowserInstance;
begin
Self.CreateBrowser;
end;
Then to create a Browser
instance add the CreateBrowserInstance
call before the first accessing the Browser
instance (which is here the Load
method):
var
pChromiumOSR: TChromiumOSR;
begin
pChromiumOSR := TChromiumOSR.Create(Self);
pChromiumOSR.OnLoadEnd := pChromiumOSRLoadEnd;
pChromiumOSR.CreateBrowserInstance;
pChromiumOSR.Load('www.google.com');
end;