I found the brilliant Delphi Chromium project for embedding Chrome in a Delphi form. It works well in Delphi7 after a bit of hacking and I can get the demo app running.
However when I do my own app with the component, I can't load my own url. I get a access violation.
Chromium2.Browser.MainFrame.LoadUrl('http://www.example.com');
The TChromium component is working and I have all the DLLs in the right place, since if I set DefaultUrl
it works fine.
I have Chromium2 in a TPageControl page and with the OnClick event of a button I call the above code. I get an AccessViolation. Mainframe is nil
.
I can't find a way around this, has anyone got this to work?
I still haven't found a resolution but I found the following work around
procedure TForm1.lblWebsiteClick(Sender: TObject);
var MainFrame : ICefFrame;
begin
MainFrame := Chromium2.Browser.GetMainFrame;
MainFrame.LoadUrl('http://www.cookingisfun.ie');
end;
The problem is that mainframe only loads after the page has loaded.
For one thing, you need to do:
if Assigned(Chromium2.Browser.MainFrame)
then Chromium2.Browser.MainFrame...
However, that is not the preferred way to navigate, but instead you should do:
Chromium1.Load( theUrl );
If you still want to use MainFrame
, do it in OnLoadEnd
event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With