CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

LaunchBrowserDialog Method (ActiveX)

2023-1-4 05:38| 发布者: admin| 查看: 646| 评论: 0|来自: AutoCAD

摘要: 启动一个对话框,用户可以在其中输入 URL。

启动一个对话框,用户可以在其中输入 URL。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.LaunchBrowserDialog(SelectedURL, DialogTitle, OpenButtonCaption, StartPageURL, RegistryRootKey, OpenButtonAlwaysEnabled)
对象

类型:实用工具

此方法适用的对象。

选定的网址

访问:仅输出

类型:字符串

所选的网址。

对话框标题

访问:仅输入

类型:字符串

要在对话框中显示的标题。

打开按钮标题

访问:仅输入

类型:字符串

“确定/打开”按钮的标题。

起始页网址

访问:仅输入

类型:字符串

要显示的初始 URL。

ReigstryRootKey

访问:仅输入

类型:字符串

用于存储持久性对话框信息的产品根密钥。此项指定有关对话框的大小、位置和其他首选项信息的信息可以跨会话存储的位置。输入空字符串以忽略此功能。

打开按钮始终启用

访问:仅输入

类型:布尔

  • True:启用“打开”按钮,允许选择文件或链接。
  • False:“打开”按钮处于禁用状态,仅当用户选择要下载的文件时启用。

返回值(RetVal)

类型:布尔

  • True:对话框已成功打开。
  • False:对话框未成功打开。

言论

最后一个参数“打开按钮始终启用”确定用户除了可以选择可下载的文件之外,是否还可以选择 HTML 链接。

例子

工 务 局:

Sub Example_LaunchBrowserDialog()
    ' This example will prompt the user for a URL to download and will verify that
    ' a proper URL was entered.  After downloading, the example will attempt to load
    ' the downloaded URL as a drawing.
    '
    ' * Note: Remember to delete the downloaded file from your disk drive when finished.
    
    Dim Utility As AcadUtility
    Dim URL As String, DestFile As String, FileURL As String
    
    Set Utility = ThisDrawing.Utility   ' Connect to Utility object
    
GETURL:
    ' Prompt user for a URL to download.  This should be a URL to an AutoCAD drawing file.
    URL = InputBox("Enter the complete URL of the file you wish to download. " & _
                    "Enter BROWSER to select the URL from a web browser", _
                    "Enter URL To Download", URL)
    
    URL = Trim(URL)                     ' Get rid of blank spaces
    
    If URL = "" Then Exit Sub           ' Did user cancel

    ' Does the user want to select from a browser?
    If StrComp(URL, "BROWSER", vbTextCompare) = 0 Then
        Utility.LaunchBrowserDialog _
        URL, "AutoCAD Browser", "Open", "https://www.autodesk.com", "ACADBROWSER", True
        
        GoTo GETURL     ' Return to display chosen URL and allow modifications
    End If

    ' Determine if user entered a valid URL; if not, prompt again
    If Not (Utility.IsURL(URL)) Then
        MsgBox "The URL you entered is not valid.  Make sure the syntax is a valid URL."
        GoTo GETURL
    End If
        
    ' Download URL
    Utility.GetRemoteFile URL, DestFile, True
    
    ' Display downloaded file information
    MsgBox URL & " was downloaded to: " & DestFile & vbCrLf & vbCrLf & _
           "Press any key to attempt to load the new file as a drawing."

    ' Attempt to load file as drawing; if an error occurs, this was probably not a drawing
    ' file, but rather the text from a web page.
    ' Try loading the downloaded file into a text editor to view the contents.
    On Error Resume Next
    ThisDrawing.Application.Documents.Open DestFile
    If Err.Number <> 0 Then
        MsgBox "Error loading downloaded file as a drawing: " & Err.Description & vbCrLf & vbCrLf & _
               "This is probably not a valid drawing file!"
    End If
    On Error GoTo 0
    
    ' Use IsRemoteFile to determine if this file was downloaded from a URL.
    ' If it was, display the URL it was downloaded from
    '
    ' * Note: Although the results IsRemoteFile will return are already known because
    ' the file was just downloaded, it is important to know how this
    ' method can be used.
    If Utility.IsRemoteFile(DestFile, FileURL) Then
        MsgBox "The file: " & DestFile & " is a downloaded file and was downloaded from: " & FileURL
    Else
        MsgBox "The file: " & DestFile & " is not a downloaded file."
    End If

End Sub

Visual LISP:

Not available

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 13:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部