WebViewGadget ignores WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS

Windows specific forum
mve001
New User
New User
Posts: 5
Joined: Fri Nov 15, 2024 2:01 pm

WebViewGadget ignores WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS

Post by mve001 »

Hi everyone,

I am trying to create a WebViewGadget that honors the settings passed through WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS, specifically "--force-device-scale-factor=1".

Currently, WebGadget does honor the setting, WebViewGadget does not. I am running PureBasic 6.12 LTS on Windows 11.

Code: Select all

If OpenWindow(0, 0, 0, 1024, 1024, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
    SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--force-device-scale-factor=1")
    
    ; does respect WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
    ; WebGadget(0, 0, 0, 1024, 1024, "https://www.purebasic.com", #PB_Web_Edge) 
    
    ; doesn't respect WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS
    WebViewGadget(0, 0, 0, 1024, 1024)
    SetGadgetText(0, "https://www.purebasic.com")

    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf
Is this a bug or by design?
Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: WebViewGadget ignores WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS

Post by Fred »

It's not really a bug because we also use this env var to setup the WebViewGadget() but I admit it should be better to mix content instead of replacing it.
mve001
New User
New User
Posts: 5
Joined: Fri Nov 15, 2024 2:01 pm

Re: WebViewGadget ignores WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS

Post by mve001 »

Thanks for your swift reply. I'd have no problem using WebGadget over WebViewGadget except WebGadget does not support "BindWebViewCallback" or "WebViewExecuteScript". Does this mean WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS will work with WebViewGadget in a future update?
Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: WebViewGadget ignores WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS

Post by Fred »

I will try to do it
mve001
New User
New User
Posts: 5
Joined: Fri Nov 15, 2024 2:01 pm

Re: WebViewGadget ignores WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS

Post by mve001 »

I don't know if it will help you, but I've now slightly modified the code from

viewtopic.php?p=618050&hilit=CreateCore ... ns#p618050

by adding

Code: Select all

SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--force-device-scale-factor=1")

to both

Code: Select all

My_CreateCoreWebView2EnvironmentWithOptions
and

Code: Select all

My_CreateWebViewEnvironmentWithOptionsInternal
Now WebViewGadget respects the setting.
Post Reply