WebView

WebView

Delphi and C++ Builder component to host web content in your applications.
  • uses Microsoft WebView2 API
  • requires WebView2 Runtime version 96.0.1054.31 or newer
  • supports Delphi/C++ Builder 5 - 11 and Lazarus 2.0.12
  • source code included in registered version
  • royalty free distribution in applications

Download and order

Order WebView license $80,- USD (license for one developer)
Order WebView multi-license $240,- USD (license for all developers in company)
Order WebView year upgrades license $40,- USD (registered users only)
Order WebView year upgrades multi-license $120,- USD (registered multi-license users only)

FAQ

What version of Edge (Chromium) browser is required?
WebView2 Runtime has to be installed. WebView2 API can't use Edge browser: path containing \Edge\Application\ is explicitly tested and disallowed.
WebView2 Runtime is deployed with many applications, including Microsoft Office, and it will be inbox in Windows 11 machines.

How can I allow OnWebResourceRequested events?
Set URI filter:
							WebView.AddFilter;
							
How can I set custom response?
procedure TFormMain.WebViewWebResourceRequested(Sender: TObject;
  const Request: TWebResourceRequest; var Response: TWebResourceResponse);
const Content = '<html><body>Hello!</body></html>';
begin
  Response := WebView.CreateResponse;
  Response.Content.Write(Content, Length(Content));
end;
							
What format is accepted in the Language property?
The format is language[-country] where language is the 2-letter code from ISO 639 and country is the 2-letter code from ISO 3166. Examples: SK, SK-SK, EN-SK, EN-US.

Why is the Active property False after setting it to True?
Active property is updated asynchronously. Use OnActive event to detect when Active value is changed.

How can I print the web page?
WebView.ExecuteScript('window.print()', nil);
							
How can I convert web page to PDF format?
WebView.PrintToPdf('C:\webpage.pdf', nil, nil);
							
How can I obtain HTML content of the web page?
uses WinJson;

WebView.ExecuteScript('document.documentElement.outerHTML',
  procedure (const JsonResult: string)
  var Json: TJson;
  begin
    with TJsonParser.Create do
    try
      Json := ParseUtf8(JsonResult);
      try
        ShowMessage((Json as TJsonString).Value);
      finally
        Json.Free;
      end;
    finally
      Free;
    end;
  end);		
							
Note: WinJson unit form JSON Library is needed.

How can I log to Google account?
Set user agent in OnActive event handler to some non-default value:
procedure TFormMain.WebViewActive(Sender: TObject);
begin
  WebView.UserAgent := 'Embedded browser';
end;
							

Related links