我会用控件实现标准保存文件的对话框。但是要多带一个ocx。记得api也可以的,哪个函数?最好有简单的例子,谢谢!

解决方案 »

  1.   

    Private Type OPENFILENAME
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        nFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
    End Type
    Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
    Dim OFName As OPENFILENAMEPrivate Sub Command1_Click()
    CommonDialog1.FileName = "test.exe"
    CommonDialog1.Filter = "*.exe"
    CommonDialog1.ShowSave
    End SubPrivate Sub Command2_Click()
        Dim sFile As String
        sFile = ShowSave
        If sFile <> "" Then
            MsgBox "You chose this file: " + sFile
        Else
            MsgBox "You pressed cancel"
        End If
    End Sub
    Private Sub Form_Load()
        Command2.Caption = "ShowSave"
    End Sub
    Private Function ShowSave() As String
        OFName.lStructSize = Len(OFName)
        
        OFName.hwndOwner = Me.hWnd
        
        OFName.hInstance = App.hInstance
        
        OFName.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
        
        OFName.lpstrFile = Space$(254)
        
        OFName.nMaxFile = 255
        
        OFName.lpstrFileTitle = Space$(254)
        
        OFName.nMaxFileTitle = 255
        
        OFName.lpstrInitialDir = "C:\"
        
        OFName.lpstrTitle = "Save File"
        
        OFName.flags = 0    
        If GetSaveFileName(OFName) Then
            ShowSave = Trim$(OFName.lpstrFile)
        Else
            ShowSave = ""
        End If
    End Function
      

  2.   

    多谢!呵呵,online 是不是 24小时 online 啊? 总是受到你的帮助!感谢感谢!