The Launch BrowserDialog Method

Use the LaunchBrowserDialog method to perform a Hypertext Transfer Protocol (HTTP) request, displaying a document using the default Web browser. It can't verify or validate URLs; it simply opens the browser and sends the request, exactly the way launching a favorite works in Internet Explorer or launching a bookmark works in Netscape. This method sets OutputURL to the URL the user selects. It returns True if the Web browser successfully launched and the user selected a file, or it returns False to indicate failure or that the user didn't select a file. This method has the following syntax:

blnStatus = UtilityObject.LaunchBrowserDialog(OutputURL, _

Title, SelectCaption, StartingURL, PreferencesKey, SelectLinks)

Table 7-18 explains this method's parameters.

Table 7-18. The LaunchBrowserDialog Method's Parameters






Output. The URL of the remote file the user selected.



A caption for the Web browser dialog.



A caption for the OK/Open button.



The starting URL for the Web browser.



The product root key for storing persistent Web browser dialog information. This key specifies where to store information about the size, position, and other preferences information of the dialog and can be stored across sessions. Leave empty to disregard this functionality.



Input Only. If True, the Open button is enabled, allowing a file or link to be selected. If False, the Open button is disabled and is enabled only when the user selects a file for download.

The RegistryRootKey parameter stores the browser window's size and location in the Windows Registry. This lets your application make the Web browser appear with the same size and location each time it is called. The information is stored in HKEY_CURRENT_USER and so is specific to each user. If you don't want to use this capability, pass a null (empty) string in this parameter.

The OpenButtonAlwaysEnabled parameter enables URL link selection. If True, the Select button is enabled at all times, and the browser can return any URL, whether it's an actual file or just a link. Use this if your program just needs to obtain a URL from the user and doesn't need to actually open or work with the contents of a remote file.

The following example uses LaunchBrowserDialog to get a URL from the user and displays the selection in a message box. Figure 7-4 illustrates this code in action.

Public Sub TestLaunchBrowserDialog() Dim strStartUrl As String Dim strInput As String Dim blnStatus As Boolean strStartUrl = InputBox("Enter a URL", , "")

With ThisDrawing.Utility

If .IsURL(strStartUrl) = False Then

MsgBox "You did not enter a valid URL" Exit Sub End If blnStatus = .LaunchBrowserDialog(strInput, _

"Select a URL", _ "Select", _ strStartUrl, _ "ContractCADDgroup", True)

If Not blnStatus Then

MsgBox "You cancelled without selecting anything" Exit Sub End If

If strStartUrl = strInput Then

MsgBox "You selected the original URL"


MsgBox "You selected: " & strInput End If End With End Sub

Figure 7-4. Getting output from TestLaunchBrowserDialog

Was this article helpful?

0 0

Post a comment