TEdgeBrowser 是由微软公司提供的,需要先安装Edge浏览器或安装Edge的运行包;因为限制(不多说)导致直接使用DelphiXE11的 GetIt功能无法连接服务器,所以只有使用手动的方式来进行安装控件
原文参考Embarcadero官方的文档: Using TEdgeBrowser Component and Changes to the TWebBrowser Component – RAD Studio (embarcadero.com)
步骤一:先确保开发电脑上有Edge浏览器;如果有则掠过此步;如果没有可以安装Edge浏览器或者安装Edge的运行包 运行包下载地址
步骤二:打开Delphi XE11;安装控件 Component->New Component






步骤三:保存工程并编译安装;至此TEdgeBrowser控件就安装好了;目前该控件只支持VCL,不支持FMX
下面就开始开发了;新建一个VCL项目,拖入EdgeBrowser

实现代码很简单:在FormShow中调用
edgbrwsr1.Navigate('https://www.baidu.com');
Pascal运行一下,白的;哦,看看上面开头的Embarcadero官方文档;原来是缺少支持库WebView2Loader.dll;

需要到微软官网下载,地址 NuGet Gallery | Microsoft.Web.WebView2 1.0.2592.51

下载好后 microsoft.web.webview2.1.0.2592.51.nupkg 的后缀名修改为zip; 解压打开,提取\build\native\x86\WebView2Loader.dll 和 \build\native\x64\WebView2Loader.dll;

根据你开发程序把对应的WebView2Loader.dll放到编译输出路径下即可,我开发的是64位程序,放入从 \build\native\x64\WebView2Loader.dll提取的WebView2Loader.dll库后,运行;
走你~~ 期待的画面出现了

但是点击一下后会在Edge浏览器中打开新的页面,稍微设置一下
//需要在控件的NewWindowRequested事件中,添加如下代码即可防止打开新的页面
procedure TForm3.edgbrwsr1NewWindowRequested(Sender: TCustomEdgeBrowser;
Args: TNewWindowRequestedEventArgs);
var
newWin:TNewWindowRequestedEventArgs;
begin
Args.ArgsInterface.Set_NewWindow((Sender as TEdgeBrowser).DefaultInterface);
end;
Pascal怎么样~ 还不错吧? 更多的功能需要自己添加,浏览器兼容性较好,比自带的TWebBrowser兼容性好得多,祝大家开发顺利~~~
