Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

embedded shell.explorer.2 async

edited June 11 in OpenInsight
Is it possible to load a url asynchronously? I know of the navigate and navigate2 methods, but they both block OI until the page is loaded. I want the browser to return immediately (not wait for the page to load) as the page takes about 2 seconds to load which is slow. I read that you can asynchronously load a url in a new tab, but I don't know how to get that working.

https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752093(v=vs.85)#remarks

Apparently I need to pass some "flags" to the method, but I have no idea how to do that:

Remarks
The WebBrowser control or InternetExplorer object can browse to any location in the local file system, on the network, or on the World Wide Web.

The post data specified by PostData is passed as a SAFEARRAY Data Type structure. The Variant should be of type VT_ARRAY|VT_UI1 and point to a SAFEARRAY Data Type. The SAFEARRAY Data Type should be of element type VT_UI1, dimension one, and have an element count equal to the number of bytes of post data.

In Microsoft Internet Explorer 6 or later, you can navigate through code only within the same domain as the application hosting the WebBrowser control. Otherwise, this method and Navigate2 are disabled.

In Windows Internet Explorer 7, when you specify the navOpenInNewTab flag or the navOpenInBackgroundTab flag, do not combine them with other parameters (TargetFrameName, PostData, Headers) or with other BrowserNavConstants flags. If tabbed browsing is disabled, or if a tab cannot be created, the call will fail. If this happens, choose another navigation method, such as navOpenInNewWindow.

Note New tabs are opened asynchronously; this method returns as soon as the tab is created, which can be before navigation in the new tab has started. The IWebBrowser2 object for the destination tab is not available to the caller. Tab order is not guaranteed, especially if this method is called many times quickly in a row.



Note New tabs are opened asynchronously; this method returns as soon as the tab is created, which can be before navigation in the new tab has started. The IWebBrowser2 interface for the destination tab is not available to the caller. Tab order is not guaranteed, especially if this method is called many times quickly in a row.

When navOpenInNewWindow or navOpenInNewTab is specified, the caller does not receive a reference to the WebBrowser object for the new window, so there is no immediate way to manipulate it.



Comments

  • edited June 11
    Navigate2 takes five parameters. The first is the URL, and the second is a set of flags. Possible flags values are:

    Equ NavOpenInNewWindow$ to 1 Equ NavNoHistory$ to 2 Equ NavNoReadFromCache$ to 4 Equ NavNoWriteToCache$ to 8 Equ NavAllowAutosearch$ to 16 Equ NavBrowserBar$ to 32 Equ NavHyperlink$ to 64 Equ NavEnforceRestricted$ to 128 Equ NavNewWindowsManaged$ to 256 Equ NavUntrustedForDownload$ to 512 Equ NavTrustedForActiveX$ to 1024 Equ NavOpenInNewTab$ to 2048 Equ NavOpenInBackgroundTab$ to 4096 Equ NavKeepWordWheelText$ to 8192 Equ NavVirtualTab$ to 16384 Equ NavBlockRedirectsXDomain$ to 32768 Equ NavOpenNewForegroundTab$ to 65536

    These are flags, so you can pass more than one of them by adding them together. Give NavOpenInBackgroundTab$ a try and let us know if it works.
  • Thanks, but it doesn't work. The good news is that I actually looked into the slowness, instead of just assuming that it was the browser, and it turns out that the slowness was caused by me using the send_event to trigger an action...

    I need to open a form for a certain key but the form could already be open. So I open the form and then send an event to load the key. But it turns out that this is a lot slower than just closing the form, opening the form and then loading the key in the create event.

    No idea why though.
  • edited June 15
    Out of curiosity, how are you trying to load the key in an open form?

    set_property(..... ) send_event(@Window, "READ")
    I assume I've oversimplified.
  • it's not a bound form
Sign In or Register to comment.