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