登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> SoftHub关联区 >> 主题: [cef]dcef3 在 delphi7 中要调用 GetMainFrame 来代替 MainFrame 属性     [回主站]     [分站链接]
[cef]dcef3 在 delphi7 中要调用 GetMainFrame 来代替 MainFrame 属性
clq
浏览(235) - 2019-08-10 19:50:38 发表 编辑

关键字: cef

[2024-02-29 09:32:08 最后更新]
[cef]dcef3 在 delphi7 中要调用 GetMainFrame 来代替 MainFrame 属性

奇怪的是 decf3 的 demo 又是可以的,大家自己研究吧,反正目前要这样用。
内容来自
https://www.cnblogs.com/xtfnpgy/p/9285377.html
https://stackoverflow.com/questions/17640526/delphi-tchromium-load-from-variable-function-not-working#

--------------------------------------------------

Delphi TChromium Load From Variable Function Not Working
Ask Question
Asked 6 years ago
Active 8 months ago
Viewed 2k times
0

I'm trying to execute this code in Form1.Activate Event:

Chromium.Browser.MainFrame.LoadString('<html>erg</html>', '');

But i get ACCESS VIOLATION error, whats a problem? What i'm doing wrong?

Here is Code(not full):

    //-------------------------FORM ACTIVATE BEGIN
Form1.DoubleBuffered:=True;
//Get Task Panel Size BEGIN
TPanel.cbSize := SizeOf(TPanel);
ShAppbarMessage(ABM_GETTASKBARPOS, TPanel);
Task_Panel_Size:=(TPanel.rc.bottom - TPanel.rc.top);
//Get Task Panel Size END

    //Maximaze BEGIN
    FormMaximize();
    //Maximaze END

    //Load Default Page\\\\\\\\\\\\
    //Load First Part--ExtractFilePath(Application.ExeName)+'Apps\Speed_Dials\index_Part1.html'
    //File_get_contents(ExtractFilePath(Application.ExeName)+'Apps\Speed_Dials\index_Part1.html');
    Chromium.Browser.MainFrame.LoadString('<html>erg</html>', '');
    //Chromium.Load(ExtractFilePath(Application.ExeName)+'Apps\Speed_Dials\index_Part1.html');

    //-------------------------FORM ACTIVATE END

    Problem is Solved, The Problem Was in that, what this Method not works in Delphi7 and thefor gives ACCESS VIOLATION error. But it works great in Delphi 2010 :) Thanks to everybody for helping :)

delphi tchromium
shareimprove this question
edited Jul 14 '13 at 20:29
asked Jul 14 '13 at 14:58
Priler
251010 bronze badges

    Where in that chained member access is the AV. Break it into multiple lines with a single member access on each. Also, don't hide the error message from us. Give the full error message, verbatim. – David Heffernan Jul 14 '13 at 16:18
    Full errror is: Access violation at address 0047EB20 in module 'Project1.exe'. Read of address 00000000. – Priler Jul 14 '13 at 16:49

add a comment
3 Answers
active
oldest
votes
0

Have you tried on Form1.Create Event? Does it require it to be created as in "Chromium.Create"?

try this

var
  frame: ICefFrame;
  source: ustring;
begin
  if Chromium.Browser = nil then
   showmessage('Not created');

  frame := Chromium.Browser.MainFrame;
  source := '<html>erg</html>';
  frame.LoadString(source, '');

end;

shareimprove this answer
edited Jul 14 '13 at 17:03
answered Jul 14 '13 at 15:51
Departure
4888 bronze badges

    I've tried in Form1.Create and in All events, But it not works... – Priler Jul 14 '13 at 16:45
    There is no Create method – Priler Jul 14 '13 at 16:46
    Using this, i get this: [Error] Unit1.pas(117): Undeclared identifier: 'ICefFrame' [Error] Unit1.pas(118): Undeclared identifier: 'ustring' [Error] Unit1.pas(141): Missing operator or semicolon [Error] Unit1.pas(141): Incompatible types: 'Cardinal' and 'String' [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' – Priler Jul 14 '13 at 17:05

Try ustring as they use that in there demo apps from what I read and also show a message box if Chromium.Browser = nil then you will know if its actually created or not – Departure Jul 14 '13 at 17:05

    Sorry, Sorry it Works!!! – Priler Jul 14 '13 at 17:10

show 4 more comments
0

In Delphi 7 I kept getting an access violation error and changed

frame := Chromium.Browser.MainFrame;

to

frame :=Chromium.Browser.GetMainFrame;

I don't know why that works because I'm totally rubbish at this, but it does. Hope this helps someone.
shareimprove this answer
edited Apr 4 '16 at 20:29
pfnuesel
6,4571010 gold badges4040 silver badges5555 bronze badges
answered Apr 4 '16 at 20:01
Dan1
144 bronze badges
add a comment
0

you sould add second parametr about:blank ie.

TChromium.Browser.MainFrame.LoadString ('<html>something</html>', 'about:blank');

shareimprove this answer
answered Nov 14 '18 at 11:27







clq  2019-08-10 19:51:08 发表 编辑

 Delphi中Chrome Chromium、Cef3学习笔记(六)
一.CEF加载网页时空白

  chrm1.Load(‘你的网址’);

出现空白,跟踪进去:

    frm := FBrowser.MainFrame;  //此时为nil ,可改为:

    frm := FBrowser.GetMainFrame;  

其他地方同上;


后续待更新。。
二、CEF程序退出时报错
 {$R *.res}
 
procedure RegisterSchemes(const registrar: ICefSchemeRegistrar);
begin
  registrar.AddCustomScheme('local', True, True, False);
end;


begin
//  CefCache := getEnvironmentVariable('USERPROFILE')+'\GetTBData\cookies\';
 
  CefCache := 'cache';
  CefOnRegisterCustomSchemes := RegisterSchemes;
  CefSingleProcess := False;
  if not CefLoadLibDefault then
    Exit;


//  CefUserAgent := 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;';
//  CefUserAgent := 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11';
  Application.Initialize;
  Application.CreateForm(TuMain, uMain);
  Application.Run;
end.
三、Cef3加载flash网页方法:

修改ceflib.pas:

  procedure TInternalApp.OnBeforeCommandLineProcessing(const processType: ustring;
      const commandLine: ICefCommandLine);
  begin
    CommandLine.AppendSwitch('ppapi-out-of-process');
    CommandLine.AppendSwitchWithValue('ppapi-flash-version', '22.0.0.168');
    CommandLine.AppendSwitchWithValue('ppapi-flash-path', 'Plugins\\pepflashplayer.dll');


    if Assigned(CefOnBeforeCommandLineProcessing) then
      CefOnBeforeCommandLineProcessing(processType, commandLine);
  end;
网上下载pepflashplayer.dll放入..\Plugins\\目录下面。

四、cef3启动加载flash网页时Dos窗口闪一下的问题

网上的解决方法,参考此文。

http://blog.csdn.net/zx2356/article/details/51514403

按照该文及提供的下载挂钩createProcessA,在xp上无效。

2.解决方法

有可能createprocessw也得挂钩。但懒得修改了。因此决定改为反编译flash插件,看看显示命令行窗口的逻辑。

反编译flash插件。发现显示cmd的逻辑是,读取环境变量comspec(cmd.exe的全路径),读取到就执行它,读取不到执行cmd.exe.

用winhex修改flash插件,搜索comspec为soms1ec,修改cmd.exe为cm1.exe.

重新测试,成功。


修改后插件下载链接

http://download.csdn.net/detail/qsy2000/9768385


转载请注明出处,原文地址:

http://blog.csdn.net/xtfnpgy/article/details/71703317

分类 Delphi中Chrome Chromium学习笔记



总数:1 页次:1/1 首页 尾页  
总数:1 页次:1/1 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1