WebBrowserSet

Using WebView2

Description

Configures the settings for the WebBrowser control. The global settings are also configured.

Note that some settings must be set before the WebBrowser control is initialized. These settings should be set in the application Open event.

Syntax

WebBrowserSet (string n, string v)

Argument

Description

n

The name of the setting that is case insensitive. The setting can be:

Note

The settings including RuntimeMode, FixedVersionRuntimePath, allow-file-access-from-files, UserDataFolder, Language, and UserAgent must be set before the WebBrowser control is initialized. It is recommended that you set it in the application Open event. If you have run the application (that includes the WebBrowser control) from PowerBuilder IDE, you may need to restart the application and the PowerBuilder IDE before the program can successfully initialize the WebBrowser control again.

  • RuntimeMode -- The distribution mode of WebView2 Runtime. This setting has a higher precedence than the setting in the IDE > Application properties dialog box.

  • FixedVersionRuntimePath -- The path of WebView2 Runtime Fixed Version. Both the relative path and absolute path are supported.

  • DownloadPath -- The default download path. Both the relative path and absolute path are supported. By default, the system default download path will be used, for example, "C:\Users\appeon\Downloads" in 64-bit Windows 10.

  • allow-file-access-from-files -- Whether to allow access to the local files (XML etc.). The value is "true" or "false" (the default).

  • UserDataFolder -- The folder that stores user data. Both the relative path and absolute path are supported. The default user data folder is %temp%\PB220UDF in the development machine and %temp%\<appname>UDF at the client.

  • Language -- The language of WebBrowser control to be set.

  • UserAgent -- The User-Agent request header that contains a characteristic string that allows the network protocol peers to identify the application type, operating system, software vendor or software version of the requesting software user agent. The default value of UserAgent cannot be obtained until the WebBrowser control is initialized and created.

v

The value of the setting to be set.

  • When the name of the setting is "RuntimeMode", the following values can be specified:

    0 -- Use the WebView2 Evergreen Runtime.

    1 -- Use the WebView2 Runtime Fixed Version.

    2 -- Use the WebView2 Evergreen Runtime by default; if it does not exist, use the Fixed Version. If you modify this value, you must restart PowerBuilder IDE and the application for the value to take effect; and this value has a higher precedence than the setting in the IDE > Application properties dialog box.

  • When the name of the setting is "Language", this value is used to set the language in the UI of WebBrowser control, such as the context menu and the default dialog box. And it is also used in the accept-languages HTTP request header sent to the website.

    The format is language[-country] in which language is a two letter code in ISO 639 and country is a two character code in ISO 3166.

  • When the name of the setting is "UserDataFolder", this value is used to set the user data directory.


Return value

Integer.

Returns values as follows. If any argument's value is null, the method returns null.

  • 1 -- Success

  • -1 -- Failed to execute the line.

  • -2 -- Failed to initialize the control and obtain the WebBrowser object. The WebView2 is invalid.

  • -4 -- The target path does not exist.

  • -5 -- The URI is invalid.

  • -6 -- The specified download task does not exist.

  • -8 -- The setting item does not exist.

  • -9 -- The path is invalid or does not exist.

  • -11 -- Unknown error.

  • -12 -- Invalid event name.

  • -14 -- Invalid argument.

  • -15 -- Failed to create screenshot file.

  • -16 -- There is a print job in progress, which cannot be closed.

  • -17 -- Could not find the corresponding item.

Examples

The following example configures the language settings for the WebBrowser control in the application Open event.

long ll_Ret

ll_Ret =WebBrowserSet("Language", "de-DE")

See also

WebBrowserGet

Using CEF

Description

Configures the settings for the WebBrowser control.

Syntax

WebBrowserSet (string n, string v)

Argument

Description

n

The name of the setting. The setting can be:

  • CachePath -- The folder that stores the web page cache, cookies etc. You can specify a directory or use the default directory which uses the system environment %HOMEPATH% and %TEMP%, for example, C:\Users\appeon\AppData\Local\Temp\pbcefcache.

    CachePath must be set before the WebBrowser control is initialized. It must be an absolute path, and cannot be a relative path.

  • UserDataPath -- The folder that stores the user data dictionary. You can specify a directory or use the default directory which uses the system environment %HOMEPATH% and %TEMP%, for example, C:\Users\appeon\AppData\Local\pbcef\User Data\Dictionaries.

    UserDataPath must be set before the WebBrowser control is initialized. It must be an absolute path, and cannot be a relative path.

  • DownloadPath -- The folder that stores the downloaded files etc. You can specify a directory or use the default directory which uses the system environment %HOMEPATH% and %TEMP%, for example, C:\Users\appeon\AppData\Local\Temp\pbcefdownload.

    DownloadPath must be set before the WebBrowser control starts downloading files. It must be an absolute path, and cannot be a relative path.

  • UserAgent -- The User-Agent request header that contains a characteristic string that allows the network protocol peers to identify the application type, operating system, software vendor or software version of the requesting software user agent.

    UserAgent must be set before the WebBrowser control is initialized.

  • ProxyAuto -- Whether to use auto proxy detection. The value could be 1 or 0 (the default). Auto proxy detection is used if it is set to 1.

  • ProxyPacUrl -- The URL address of the PAC file. It is unsupported to load the PAC file on the local directory via file:/// (you will have to put the file on the server and load it via http or https).

  • ProxyAddress -- The address of the proxy server.

  • ProxyPort -- The port of the proxy server. The default value is -1.

  • ProxyUser -- The user name that will be authenticated by the proxy server.

  • ProxyPassword -- The password that will be authenticated by the proxy server.

    WebBrowser supports auto proxy detection, PAC (proxy auto configuration) file setting, and manual proxy settings. The priority order of the settings is: auto proxy detection > PAC file setting > manual proxy settings. By default the IE proxy is used.

    If the proxy setting is set before the WebBrowser control is initialized, it will be effective to all Web pages loaded; if it is set before the Navigate operation, then it will be effective to only the Web page being navigated.

  • allow-file-access-from-files -- Whether to allow access to the local files (XML etc.). The value is "true" or "false" (the default).

  • enable-media-stream -- Whether to allow access to the microphone or camera. The value is "true" or "false" (the default).

v

The value of the setting to be set.


Return value

Integer.

Returns the following error code:

  • 1 -- Success

  • -7 -- CEF has been initialized, and the current item can only be set before CEF initialization.

  • -8 -- The setting name does not exist.

  • -9 -- The path is invalid or does not exist.

Examples

The following example configures the proxy settings for the WebBrowser control in the application Open event.

Open(string commandline)
{
    WebBrowserSet ("ProxyAddress", "192.168.5.16")
    WebBrowserSet ("ProxyPort", "8080")
    WebBrowserSet ("ProxyUser", "Admin")
    WebBrowserSet ("ProxyPassword", "123Test")
}

See also

WebBrowserGet