1

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

Priler
  • 55
  • 1
  • 10
  • 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

3 Answers3

1

you sould add second parametr about:blank ie.

TChromium.Browser.MainFrame.LoadString ('<html>something</html>', 'about:blank');
icinema gr
  • 310
  • 3
  • 14
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;
Departure
  • 48
  • 8
  • 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
  • I have forgot to include ceflib.pas file into my USINGs :) Thanks for helping, it works very well! – Priler Jul 14 '13 at 17:11
  • Hmm, Your code is working, but if i'm using this : Chromium.Browser.MainFrame.LoadString('YO',''); Its not works, why? – Priler Jul 14 '13 at 17:12
  • Its not works again :( I pasted your code, included ceflib.pas file and it have worked, but when im closed my programm and runned it again, it gived same error(Access violation)... :( – Priler Jul 14 '13 at 17:14
  • If i trying this: if Chromium.Browser.MainFrame = nil then showmessage('Not created'); It says Not Created – Priler Jul 14 '13 at 17:25
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.

pfnuesel
  • 14,093
  • 14
  • 58
  • 71
Dan1
  • 1
  • 4