Re: TChromium control - Initialization issue
Posted: Sat Jul 25, 2020 7:24 pm
Hi,
Could you please help me on my below mentioned things?
My application is using TWebBrowser and i am trying to replace with TChromium (CEF4 Delphi).
I am using CEFWindowParent and TChromium.
Need your help on following things:
1) How to achieve "OnBeforeNavigate2" (which is in TWebBrowser) in TChromium (CEF4 Delphi)?
2) I am using TWebBrowser in one of my screen
2.1) I have method called LoadSummary(aHTML: String).
2.2) Having 4 Comboboxe's in my screen
2.3) Calling LoadSummary(aHTML: String) on each ComboBox "OnChange" event. Because i need to load the chromium browser based on the value
selected in combobox
2.4) In "FormShow" the data is loading properly in chromium browser (here also calling LoadSummary). But when i choose the the combobox value
then the browser is flickering and not able to select the value from ComboBox. I mean, whenever i try to select the data from ComboBox
immediately browser is flickering (not black screen).
Please help me to address this issue.
procedure TSummaryDialog.LoadSummaryPPT(aSummary: string);
var
lTempFilename: string;
browser: ICefBrowser;
begin
//lTempFilename := fFileCache.SaveToFile('html', aSummary);
//dChromiumBrowser.LoadURL(lTempFilename);
fSummary := aSummary;
dChromiumBrowser.LoadString(aSummary);
end;
//This will run after "FormShow" event
procedure TSummaryDialog.BrowserCreatedMsg(var aMessage : TMessage);
var
browser: ICefBrowser;
lTempFilename: string;
begin
CEFWindowParent.UpdateSize;
try
browser := TCefBrowserRef.UnWrap(Pointer(aMessage.WParam));
if browser.IsSame(dChromiumBrowser.Browser) then
begin
lTempFilename := fFileCache.SaveToFile('html', fSummary);
browser.MainFrame.LoadUrl(lTempFilename);
end;
finally
browser := nil
end;
end;
procedure TSummaryDialog.FormShow(Sender: TObject);
begin
if not(dChromiumBrowser.CreateBrowser(CEFWindowParent, '')) then
dLoadTimer.Enabled := True;
end;
procedure TSummaryDialog.dLoadTimerTimer(Sender: TObject);
begin
dLoadTimer.Enabled := False;
if not(dChromiumBrowser.CreateBrowser(CEFWindowParent, '')) and
not(dChromiumBrowser.Initialized) then
dLoadTimer.Enabled := True;
end;
Could you please help me on my below mentioned things?
My application is using TWebBrowser and i am trying to replace with TChromium (CEF4 Delphi).
I am using CEFWindowParent and TChromium.
Need your help on following things:
1) How to achieve "OnBeforeNavigate2" (which is in TWebBrowser) in TChromium (CEF4 Delphi)?
2) I am using TWebBrowser in one of my screen
2.1) I have method called LoadSummary(aHTML: String).
2.2) Having 4 Comboboxe's in my screen
2.3) Calling LoadSummary(aHTML: String) on each ComboBox "OnChange" event. Because i need to load the chromium browser based on the value
selected in combobox
2.4) In "FormShow" the data is loading properly in chromium browser (here also calling LoadSummary). But when i choose the the combobox value
then the browser is flickering and not able to select the value from ComboBox. I mean, whenever i try to select the data from ComboBox
immediately browser is flickering (not black screen).
Please help me to address this issue.
procedure TSummaryDialog.LoadSummaryPPT(aSummary: string);
var
lTempFilename: string;
browser: ICefBrowser;
begin
//lTempFilename := fFileCache.SaveToFile('html', aSummary);
//dChromiumBrowser.LoadURL(lTempFilename);
fSummary := aSummary;
dChromiumBrowser.LoadString(aSummary);
end;
//This will run after "FormShow" event
procedure TSummaryDialog.BrowserCreatedMsg(var aMessage : TMessage);
var
browser: ICefBrowser;
lTempFilename: string;
begin
CEFWindowParent.UpdateSize;
try
browser := TCefBrowserRef.UnWrap(Pointer(aMessage.WParam));
if browser.IsSame(dChromiumBrowser.Browser) then
begin
lTempFilename := fFileCache.SaveToFile('html', fSummary);
browser.MainFrame.LoadUrl(lTempFilename);
end;
finally
browser := nil
end;
end;
procedure TSummaryDialog.FormShow(Sender: TObject);
begin
if not(dChromiumBrowser.CreateBrowser(CEFWindowParent, '')) then
dLoadTimer.Enabled := True;
end;
procedure TSummaryDialog.dLoadTimerTimer(Sender: TObject);
begin
dLoadTimer.Enabled := False;
if not(dChromiumBrowser.CreateBrowser(CEFWindowParent, '')) and
not(dChromiumBrowser.Initialized) then
dLoadTimer.Enabled := True;
end;