jerik 0 Posted June 30, 2023 procedure TForm2.FormCreate(Sender: TObject); var HTML: string; begin // HTML := TResourceStream.Create(HInstance, 'index', RT_RCDATA).ToString(); HTML := '<!DOCTYPE html> <html lang="en">' + '<head> <meta charset=utf-8> ' + '<title>Test</title><style>body {background:red;}</style> ' + '</head><body> ' + '<h1>TEST</h1> <p>Dette er en tekst!</p> ' + '</body> </html>'; WebBrowser1.LoadFromStrings(HTML, ''); end; Hi! I have a resourcefile with a HTML-file that I want to load in a FireMonkey TWebBrowser. This is what I have tried and not succeed with: Share this post Link to post
programmerdelphi2k 237 Posted June 30, 2023 (edited) 1 hour ago, jerik said: This is what I have tried and not succeed with: procedure TForm1.Button1Click(Sender: TObject); var HTML: string; BURL: string; begin BURL := ''; // // HTML := TResourceStream.Create(HInstance, 'index', RT_RCDATA).ToString(); HTML := '<!DOCTYPE html> <html lang="en">' + { } '<head> <meta charset=utf-8> ' + { } '<title>Test</title><style>body {background:red;}</style> ' + { } '</head><body> ' + { } '<h1>TEST</h1> <p>Dette er en tekst!</p> ' + { } '</body> </html>'; // WebBrowser1.LoadFromStrings(HTML, BURL); end; CONST X LITERAL Edited June 30, 2023 by programmerdelphi2k 1 Share this post Link to post
jerik 0 Posted June 30, 2023 Aha! Bad idea to place it in Form.Create. Thank you! Share this post Link to post
programmerdelphi2k 237 Posted June 30, 2023 2 minutes ago, jerik said: Bad idea to place it in Form.Create. as rule, any "critical action" should be in another place... but if strictly necessary use it! 2 Share this post Link to post
dport 0 Posted November 23, 2023 On 6/30/2023 at 7:46 PM, jerik said: Aha! Bad idea to place it in Form.Create. Thank you! Yes, there is this problem in the latest versions of Delphi. In the form create event, everything added to the webbrowser is deleted, not only that. It is also deleted when the parent changes. For example, when you move the WebBrowser parent to an object such as panel2, all the content is gone. I reported this on qualityprortal. Marco cantu wrote that this behavior is normal(!). So correction is not considered. Share this post Link to post