tadvwebbrowser set zoom factor

I just switched to the TMS AdvWebBrowser. I want to set the ZoomFactor in the OnNavigateComplete event. My previous (much older) browser object has the ZoomFactor surfaced and I could just set it. I use the CTRL+/CTRL- to set this after the fact now , but I wonder if it can be done with ExececuteJavascript();
Thanks,
Lou

Delphi 10.3
TAdvWebBrowser 1.1.4.4

Hi,

You can set the zoom factor with

uses
  AdvWebBrowser.Win;

procedure TForm1.Button1Click(Sender: TObject);
var
  c: ICoreWebView2Controller;
begin
  c := ICoreWebView2Controller(AdvWebBrowser1.NativeBrowser);
  if Assigned(c) then
  begin
    c.put_ZoomFactor(10);
  end;
end;

Where might I have found this piece of information? I did look in the TMS documentation I had. With this in hand, I found a Microsoft reference to the WebCore2 object. I'll look that over. Any TMS documentation or demos?
Thanks,
Lou

Hi,

The TAdvWebBrowser exposes the NativeBrowser property and gives access to the internal Windows APIs. the TAdvWebBrowser is a port from FNC and the zoom factor is not something that can be implemented in a cross platform way, therefore it is not exposed yet. We'll investigate if we can expose it for TAdvWebBrowser as this only targets Windows. The APIs for Windows specific are explained here (WebView2 Win32 C++ Reference | Microsoft Docs), but please note that not all APIs are implemented.

I just tried:
var PZoomFx : PDouble
begin
c.get_ZoomFactor(PZoomFx);
end;

I get an Access Violation on EmbeddedBrowserWebView.dll Write of Address.

What is PZoomFX? did you set a value? Also, are you using the latest version and did you copy the latest DLLs to the system32 & sysWow64 folders?

From AdvWebBrowser.WIn:
function get_ZoomFactor(zoomFactor: PDouble): HRESULT; stdcall;

I had assumed the PDouble to be the return var, but at second look it's not. So, I guess I don't know what to set this value to.

From the Microsoft documentation: get_zoomfactor)(double * zoomFactor)

Yes ,but in your original post you mentioned, you wanted to set the zoom factor, which is with put_zoomFactor(). If you want to retrieve the zoom factor you need to use:

uses
  AdvWebBrowser.Win;

procedure TForm1.Button1Click(Sender: TObject);
var
  c: ICoreWebView2Controller;
  zf: Double;
begin
  c := ICoreWebView2Controller(AdvWebBrowser1.NativeBrowser);
  if Assigned(c) then
  begin
    c.get_ZoomFactor(@zf);
  end;
end;

Doh! Feeling a little foolish right now. Thanks.

1 Like

No worries !