문제

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 :)

도움이 되었습니까?

해결책 2

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;

다른 팁

you sould add second parametr about:blank ie.

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

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top