Jump to content
Mauro Botta

WebView - Edge browser with local file access

Recommended Posts

Hi,

 

I'm using in my project more TWebBrowser,  i have a know problem with Internet Explorer, now ,

I know Embardero docs , like https://blogs.embarcadero.com/browsing-in-a-windows-application-from-internet-explorer-to-webview-2/ but i don't like it.

 

I have tried https://stackoverflow.com/a/52788855/537347 exampe,

 

## Using WebView (EdgeHTML) in Delphi / C++ Builder  ##

 

const
  SWebViewControlProcess = 'Windows.Web.UI.Interop.WebViewControlProcess';

type
  // Interface with functionality to interact with WebBrowser Control
  // https://docs.microsoft.com/en-us/uwp/api/windows.web.ui.iwebviewcontrol
  IWebViewControl = interface(IInspectable)
  ['{3F921316-BC70-4BDA-9136-C94370899FAB}']
    procedure Placeholder_SourceGet; safecall;
    procedure Placeholder_SourcePut; safecall;
..


 

and work fine. i can open any web sites on Windows 11 in very easy mode.

 

But i can't open any local files ( and show ) , i need show a .P7M files.

 

WinS:= TWindowsString.Create('file:\\V:\DelphiXE104_PROJECT\Test\test.xml.p7m');         don't work

WinS:= TWindowsString.Create('V:\DelphiXE104_PROJECT\Test\test.xml.p7m');                 don't work

WinS:= TWindowsString.Create('V:\DelphiXE104_PROJECT\Test\BASE_HTML_TEMPLATE.html');               don't work

 

Any Hint ?

 

 

 

 

 

from chats:

https://stackoverflow.com/questions/52766249/using-webview-edgehtml-in-delphi-c-builder/52788855#52788855

 

You declared the TWebViewControlProcess as class(TWinRTGenericImportI<IWebViewControlProcess>). According to the official documentation, it also has a second constructor with parameters. I would need to access this to create a process that allows to display local files. Can you elaborate on how to call this constructor in Delphi? 

 Oct 22 '19 at 17:50 

Share this post


Link to post

i have found any links:

 

https://social.msdn.microsoft.com/Forums/windowsapps/en-US/3e759487-ea22-4ea6-8096-ff013fb099fd/how-to-load-a-local-htmlfile-into-webview?forum=winappswithcsharp

 

and

 

https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview.navigatetolocalstreamuri?view=winrt-22000

 

Loads local web content at the specified URI using an IUriToStreamResolver.

public void NavigateToLocalStreamUri(System.Uri source, IUriToStreamResolver streamResolver);

 

 

 

 

 

Only Delphi 11 have NavigateToLocalStreamUri property.   how i can use this in Delphi 10.4.2 ?

 

 

  IWebView2 = interface(IInspectable)
  ['{D481759E-3EFF-4462-823D-FD52F9BA4CC8}']
    function get_CanGoBack: Boolean; safecall;
    function get_CanGoForward: Boolean; safecall;
    function get_DocumentTitle: HSTRING; safecall;
    function add_NavigationStarting(handler: TypedEventHandler_2__IWebView__IWebViewNavigationStartingEventArgs): EventRegistrationToken; safecall;
    procedure remove_NavigationStarting(token: EventRegistrationToken); safecall;
    function add_ContentLoading(handler: TypedEventHandler_2__IWebView__IWebViewContentLoadingEventArgs): EventRegistrationToken; safecall;
    procedure remove_ContentLoading(token: EventRegistrationToken); safecall;
    function add_DOMContentLoaded(handler: TypedEventHandler_2__IWebView__IWebViewDOMContentLoadedEventArgs): EventRegistrationToken; safecall;
    procedure remove_DOMContentLoaded(token: EventRegistrationToken); safecall;
    procedure GoForward; safecall;
    procedure GoBack; safecall;
    procedure Refresh; safecall;
    procedure Stop; safecall;
    function CapturePreviewToStreamAsync(stream: IRandomAccessStream): IAsyncAction; safecall;
    function InvokeScriptAsync(scriptName: HSTRING; arguments: IIterable_1__HSTRING): IAsyncOperation_1__HSTRING; safecall;
    function CaptureSelectedContentToDataPackageAsync: IAsyncOperation_1__IDataPackage; safecall;
    procedure NavigateToLocalStreamUri(source: IUriRuntimeClass; streamResolver: IUriToStreamResolver); safecall;
    function BuildLocalStreamUri(contentIdentifier: HSTRING; relativePath: HSTRING): IUriRuntimeClass; safecall;
 

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×