Contents - Index - Top


Using AntView in Visual FoxPro

 

Here are some specific tips for using the AntView control from within Visual FoxPro.

Please note that we're not Visual Fox Pro developers, but we have had great help from several VFP developers that have helped to improve the control as well as assisted with the examples as they are available.

 

In the AntView2 example folders under C:\Users\Public\Documents you can find code examples of using the AntView component. 

There are three example projects and each one is in their own folder. 

 

The first project is located at the "standard" folder. This example take the form of a basic browser that introduces VFP users to the AntView object and the AntViewDocument interface.

 

The second project can be found at the "advanced" folder. This example provides a browser with several additional features. Its primary purpose is to introduce the use of AntView's additional interfaces, specifically: AntViewNewWindowRequestedEventsArgs, AntViewDeferral and AntViewCookieManager. These are used to demonstrate new window (ie target="_blank") and cookie management functionality. In addition AntViewV2Plus demonstrates tab page and form related functionality.

 

The third project can be found at the "extra" folder. It showcases the OnBasicAuthenticationRequested event and associated interface, AntViewBasicAuthenticationRequestedEventArgs. These provide auto-login functionality. In addition the example demonstrates messaging between VFP and the current web page. This functionality is used to pass data and scripts between VFP and the current web page. Selected settings functionality is also demonstrated.

The "Cookies" button in this form will open a web page where we show you how you can manage (query, change, add) cookies for the current html page. This example uses synchronous methods.

The "Context menu" button opens a new form that shows an example of a custom context menu with different ways on how-to use that menu.

 

These examples have been written by Visual FoxPro developers and are very worthwhile checking out.

 

Please make sure to check out the help that you can read after pressing the "Help" button when running the examples. 

It has a lot of detailed tips for using the AntView control as a Visual FoxPro developer.

 

You can run the examples from VFP via:

 DO 'c:\users\Public\documents\antview2\examples\visual foxpro\antstart'

 

You should then get the following screen:

Note that 'AntStart' is intended for Developer use only, for simplifying access to the examples. It does not have project files and if compiled it will try to suck in everything. This is not recommended and hasn't been tested. 

 

 

By default VFP will only automatically be able to receive events for the main interface.

The AntView control however contains several more interfaces that contain events. If you want to be able to consume those events then you have to create a specific event wrapper for that. 

There's an example wrapper for the AntViewDocument interface.

You can find this example in the file avdeventsv2.prg, we keep this file up to date with the version of the control.

If you want to know how to use the Document interface, then read VFP  - Create a document object.

 

There's also an example events wrapper for the AntViewCookieManager interface in the "advanced" project folder and for the AntViewContextMenuItem interface in the "extra" folder.

Read the "Help" from within the application to read on how you can generate your own event wrappers for other interfaces.

 

Because in VFP only the form has a window handle, things work a bit different with navigation between the browser control and controls in your form.

For more info see FocusNextObject and FocusPreviousObject.

 

As Visual FoxPro does not natively support Int64 data types, there are workarounds available when the WebView2 control returns a variable that is of data type Int64. This is especially true for events with Int64 parameters, events with these parameters are not raised in VFP.

Since we can't just cut off the data to fit in Int32, we instead encode the data as hexadecimal and pass that as a string.

Below is a summary. 

 

You will want to set a property called EventsUseHexadecimal to switch the relevant events to using the hexadecimal variant.

 

Events that address this limitation:

 

Some data structures such as AntViewDownloadOperation offer the data as Int64 as well as in hexadecimal format.

The hexadecimal variant has a "Hex" suffix.

For example TotalBytesToReceiveHex

 

 

Please note that you have to select "remove examples" in the uninstall program to receive the latest updates in the examples. If you don't select that then the example project will be untouched. This is nowadays the default.

 

 

Special thanks goes to:

- Jon Goad, who wrote the initial example.

- Tam Dobie, who has done a fantastic job on writing the new examples.

 


AntView - The MS Edge WebView2 ActiveX control Date last changed: 11/05/2025