自定义打开文件对话框如何有【快速模式】的选项

Inventor 2014提供了快速装配模式,详情见此文章: http://blog.csdn.net/autodeskinventorapi/article/details/8860045 

大家知道, API可以定制自己的打开文件对话框。有开发者发现,自己的对话框显示出来,但【快速模式】(不知中文版翻译成什么,英文是Open Express) 选项不见了。

其实API文档没有提及,FileDialog.InsertMode 将影响是否这个选项的出现。缺省是true,需要设置为false。另外,即便设置了,也只是说文件对话框知道是快速打开还是常规打开,代码还需要将此信息传递给Inventor的打开文件流程。请看如下VBA代码。


‘*****module******

Option Explicit

Private oEventHandler As Class1

Private Sub StartFileOpen()
   Set oEventHandler = New Class1
End Sub
   
Private Sub EndFileOpen()
    Set oEventHandler = Nothing
End Sub




‘****even class *******

Option Explicit

Private WithEvents oEvents As FileUIEvents
Private inCustomDlg As Boolean


Private Sub Class_Initialize()
Set oEvents = ThisApplication.FileUIEvents
 inCustomDlg = False
End Sub


Private Sub Class_Terminate()
Set oEvents = Nothing
End Sub

Private Sub oEvents_OnFileOpenDialog(FileTypes() As String, ByVal ParentHWND As Long, FileName As String, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)

If inCustomDlg = False Then '  to avoid recursive callback
    inCustomDlg = True
    Dim oFileLocations As FileLocations
    Set oFileLocations = ThisApplication.FileLocations
    
    Dim FileOpenForm As FileDialog
    Call ThisApplication.CreateFileDialog(FileOpenForm)
     FileOpenForm.InsertMode = False 
    FileOpenForm.InitialDirectory = oFileLocations.Workspace
    With FileOpenForm
            ' Set the initial Directory
            .InitialDirectory = oFileLocations.Workspace
            .DialogTitle = "My File Open"
            .Filter = "Part File (*.ipt)|*.ipt" _
                      & "|Assembly File (*.iam)|*.iam" _
                      & "|Presentation File (*.ipn)|*.ipn" _
                      & "|Drawing File (*.idw)|*.idw" _
                      & "|Design element File (*.ide)|*.ide" _



            .FilterIndex = 2    ' *.iam files
            .OptionsEnabled = True
            '.Flags = cdlOFNHideReadOnly
            .ShowOpen
        End With
        FileName = FileOpenForm.FileName
        If FileOpenForm.OptionValues.Count >= 6 Then
            ' assembly has 6 options
            
            Dim index As Integer
            Dim oKey As String
            For index = 1 To FileOpenForm.OptionValues.Count
             
                 oKey = FileOpenForm.OptionValues.Name(index)
                 If oKey = "OpenExpressMode" Then
                    ' this is a Boolean for OpenExpress/Don't open Express
                    If FileOpenForm.OptionValues.Item(index) Then
                        'if OpenExpress was specified, pass it back through the context
                        Context.Add "ExpressModeBehavior", "OpenExpress"
                    End If
                 End If
            Next
             
           
        End If

        If FileName = "" Then
            HandlingCode = kEventCanceled
        Else
            HandlingCode = kEventHandled
        End If
        inCustomDlg = False
End If
End Sub


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值