使用 TChromium 时 LoadURL 出错
我发现了出色的 Delphi Chromium 项目,用于以 Delphi 形式嵌入 Chrome。经过一些修改后,它在 Delphi7 中运行良好,我可以运行演示应用程序。
但是,当我使用该组件制作自己的应用程序时,我无法加载自己的网址。我收到访问冲突。
Chromium2.Browser.MainFrame.LoadUrl('http://www.example.com');
TChromium 组件正在工作,并且我将所有 DLL 放在正确的位置,因为如果我设置 DefaultUrl
它就可以正常工作。
我在 TPageControl 页面中有 Chromium2,并通过按钮的 OnClick 事件调用上面的代码。我收到 AccessViolation。大型机nil
。
我找不到解决这个问题的方法,有人可以解决这个问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我仍然没有找到解决方案,但我找到了以下解决方法
I still haven't found a resolution but I found the following work around
问题是主机仅在页面加载后才加载。
一方面,您需要这样做:
但是,这不是首选的导航方式,而是您应该这样做:
如果您仍然想使用
MainFrame
,请在OnLoadEnd事件。
The problem is that mainframe only loads after the page has loaded.
For one thing, you need to do:
However, that is not the preferred way to navigate, but instead you should do:
If you still want to use
MainFrame
, do it inOnLoadEnd
event.遇到类似的问题,并在几个小时后找到了问题:
如果 TChromium 位于应用程序的主窗体上,则可以。
如果 TChromium 不在主窗体(或框架)上,则:
打开 cef.inc 并删除要定义的点:
<前><代码>{.$DEFINE CEF_MULTI_THREADED_MESSAGE_LOOP}
删除 DefaultURL 值,使其成为空字符串。
我用谷歌搜索了 CEF_MULTI_THREADED_MESSAGE_LOOP 但根本没有找到太多东西。
最后,存在调整大小/刷新问题(即使将对齐方式设置为 alClient)。短期内修复
crmLoadEnd 事件执行类似以下操作:
Had similar problems and after quite a few hours located the problem:
If TChromium is on the main form of the application then ok.
If TChromium is not on main form (or on a frame) then:
Open cef.inc and remove the dot to define:
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:
构建应用程序的文件夹中是否包含所有必需的 DLL?
您需要:libcef.dll、icudt.dll...
检查此线程 他们的支持小组。
当您构建/运行演示时,它们会构建在此子文件夹 (*DCC_ExeOutput*) 中:DCEF\bin\
这就是为什么它与他们合作......
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...
也遇到了这个问题。看起来 MainFrame 是在框架/窗口可见时首先创建的。
但有一个简单的方法可以解决这个问题。只需直接在 TChromium 对象上调用 .Load('about:blank') 即可。这将更早地初始化丢失的帧。
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.