delphitchromium

Delphi TChromium Load From Variable Function Not Working


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


Solution

  • 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;