Error on LoadURL with TChromium

前端 未结 5 1991
抹茶落季
抹茶落季 2020-12-10 19:13

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.

相关标签:
5条回答
  • 2020-12-10 19:46

    Had similar problems and after quite a few hours located the problem:

    1. If TChromium is on the main form of the application then ok.

    2. If TChromium is not on main form (or on a frame) then:

      1. Open cef.inc and remove the dot to define:

        {.$DEFINE CEF_MULTI_THREADED_MESSAGE_LOOP} 
        
      2. Remove DefaultURL value so it is an empty string.

    I googled CEF_MULTI_THREADED_MESSAGE_LOOP but it didn't come up with much at all.

    Lastly, had resizing/refreshing problems (even with alignment set to alClient). Short term fix is within
    crmLoadEnd event do something like:

         if crm.Height < panclient.Height then
            crm.Height := panclient.Height;
    
    0 讨论(0)
  • 2020-12-10 19:47

    Had this problem as well. It seems the MainFrame is first created when the frame/window gets visible. But there is an easy way around it. Just call .Load('about:blank') directly on your TChromium object. This will initialize the missing frame earlier.

    0 讨论(0)
  • 2020-12-10 19:49

    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.

    0 讨论(0)
  • 2020-12-10 19:51

    Do you have alll the required DLL in the folder where your application is built?

    You need: libcef.dll, icudt.dll, ...

    Check this thread on their support group.


    When you build/run the demos, they are built in this subfolder (*DCC_ExeOutput*): DCEF\bin\ which is why it works with them...

    0 讨论(0)
  • 2020-12-10 19:59

    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;
    
    0 讨论(0)
提交回复
热议问题